예제 #1
0
int speed_to_mm_fine_tune(u32 speed, int sample)
{
	unsigned int ctmp = 0;
	unsigned int tmp;
	int note = 1;
	int mm_fine_tune = 0;
	//
	speed >>= 1;
	while ((tmp=getfrequency(mmoo.flags,getlinearperiod(note<<1,0))) < speed)
	{
		ctmp = tmp;
		note++;
	}
	if (tmp != /*(int)*/speed)
	{
		if ( ((signed)tmp - (signed)speed) < ((signed)speed - (signed)ctmp))/* ...うーん */
		{
			while (tmp > speed)
			{	tmp=getfrequency(mmoo.flags,getlinearperiod(note<<1,--mm_fine_tune));}
		}
		else
		{
			note--;
			while (ctmp < speed)
			{	ctmp=getfrequency(mmoo.flags,getlinearperiod(note<<1,++mm_fine_tune));}
		}
	}
	noteindex[sample] = note - (4*OCTAVE);
	return (mm_fine_tune);
}
예제 #2
0
파일: mlutil.c 프로젝트: OS2World/LIB-SDL
int speed_to_finetune(ULONG speed,int sample)
{
    int ctmp=0,tmp,note=1,finetune=0;

    speed>>=1;
    while((tmp=getfrequency(of.flags,getlinearperiod(note<<1,0)))<speed) {
        ctmp=tmp;
        note++;
    }

    if(tmp!=(int)speed) {
        if((tmp-speed)<(speed-ctmp))
            while(tmp>speed)
                tmp=getfrequency(of.flags,getlinearperiod(note<<1,--finetune));
        else {
            note--;
            while(ctmp<speed)
                ctmp=getfrequency(of.flags,getlinearperiod(note<<1,++finetune));
        }
    }

    noteindex[sample]=note-4*OCTAVE;
    return finetune;
}
예제 #3
0
int		isdb_t_frequency(void __iomem *regs, struct mutex *lock, int addr, int channel, int addfreq)
{

	int		lp ;
	WBLOCK	wk;
	__u32	val ;
	int		tmcclock = FALSE ;
	union{
		__u8	charfreq[2];
		__u16	freq;
	}freq[2] ;

	if(channel >= MAX_ISDB_T_CHANNEL){
		printk(KERN_INFO "PT1:ISDB-T CHANNEL OVER(%i:113)\n", channel);
		return -EIO ;
	}

	freq[0].freq = getfrequency(channel, addfreq);
	freq[1].freq = getfrequency_add(channel);
	//指定周波数
	memcpy(&wk, &isdb_t_pll_base, sizeof(WBLOCK));
	wk.addr = addr ;
	// 計算した周波数を設定
	wk.value[wk.count] = freq[0].charfreq[1];
	wk.count += 1 ;
	wk.value[wk.count] = freq[0].charfreq[0];
	wk.count += 1 ;

	// 計算した周波数付加情報を設定
	wk.value[wk.count] = freq[1].charfreq[1];
	wk.count += 1 ;
	wk.value[wk.count] = freq[1].charfreq[0];
	wk.count += 1 ;

	i2c_write(regs, lock, &wk);

	for(lp = 0 ; lp < 100 ; lp++){
		memcpy(&wk, &isdb_t_pll_lock, sizeof(WBLOCK));
		wk.addr = addr;
		val = i2c_read(regs, lock, &wk, 1);
		if(((val & 0xFF) != 0XFF) && ((val & 0X50) == 0x50)){
			tmcclock = TRUE ;
			break ;
		}
	}
	if(tmcclock != TRUE){
		PT1_PRINTK(0, KERN_ERR, "ISDB-T LOCK NG(%08x)\n", val);
		return -EIO ;
	}

	memcpy(&wk, &isdb_t_check_tune, sizeof(WBLOCK));
	wk.addr = addr ;
	i2c_write(regs, lock, &wk);

	tmcclock = FALSE ;
	for(lp = 0 ; lp < 1000 ; lp++){
		memcpy(&wk, &isdb_t_tune_read, sizeof(WBLOCK));
		wk.addr = addr;
		val = i2c_read(regs, lock, &wk, 1);
		if(((val & 0xFF) != 0XFF) && ((val & 0X8) != 8)){
			tmcclock = TRUE ;
			break ;
		}
	}
	if(tmcclock != TRUE){
		printk(KERN_INFO "PT1:ISDB-T TUNE READ NG(%08x)\n", val);
		return -EIO ;
	}
	return 0 ;
}
예제 #4
0
INLINE void Ce500::computeSound(void)
{
    Csc62015 * sc = (Csc62015*)pCPU;

//    qint64 delta;
    qint64 wait2khz = getfrequency()/1000/4;
    qint64 wait4khz = getfrequency()/1000/8;

    switch ( (sc->get_imem(IMEM_SCR)>>4) & 0x07)
    {
        case 0x00 : Xout = false;
                    start2khz = 0;
                    start4khz = 0;
                    //if (fp_log) fprintf(fp_log,"XOUT LOW\n");
                    break;

        case 0x01 : Xout = true;
                    start2khz = 0;
                    start4khz = 0;
                    //if (fp_log) fprintf(fp_log,"XOUT HIGH\n");
                    break;

        case 0x02 : // 2khz
                    start4khz = 0;
                    //if (fp_log) fprintf(fp_log,"XOUT 2Khz\n");
                    if (start2khz == 0){
                        start2khz = pTIMER->state;
                        if (fp_log) fprintf(fp_log,"XOUT 2Khz INIT\n");
                        Xout = true;
                    }
//                    delta = pTIMER->state - start2khz;
                    //while
                    if ((pTIMER->state - start2khz) >= wait2khz){
                        Xout = !Xout;
                        start2khz += wait2khz;
                        if (fp_log) fprintf(fp_log,"XOUT 2Khz switch\n");
                    }
                    break;

        case 0x03 : // 4khz
                    start2khz = 0;
                    //if (fp_log) fprintf(fp_log,"XOUT 4Khz\n");
                    if (start4khz==0)
                    {
                        start4khz = pTIMER->state;
                        if (fp_log) fprintf(fp_log,"XOUT 4Khz INIT\n");
                        Xout = true;
                    }
//                    delta = pTIMER->state - start4khz;
                    //while
                    if (( pTIMER->state - start4khz) >= wait4khz)
                    {
                        Xout = !Xout;
                        start4khz += wait4khz;
//                        if (fp_tmp) fprintf(fp_tmp,"%s\n",tr("switch XOUT to %1 : wait = %2  -  delta=%3  new:%4 - old:%5 ").arg(Xout).arg(wait4khz).arg(pPC->pTIMER->state - start4khz).arg(pPC->pTIMER->state).arg(start4khz).toLocal8Bit().data());


                        if (fp_log) fprintf(fp_log,"XOUT 4Khz switch\n");
                    }
                    break;

        case 0x04 : Xout = false;
                    start2khz = 0;
                    start4khz = 0;
                    //if (fp_log) fprintf(fp_log,"XOUT LOW");
                    break;

        case 0x05 : Xout = true;
                    start2khz = 0;
                    start4khz = 0;
                    //if (fp_log) fprintf(fp_log,"XOUT HIGH\n");
                    break;

        case 0x06 :
        case 0x07 : // Xin -> Xout
                    Xout = Xin;
                    start2khz = 0;
                    start4khz = 0;
                    break;
    }

    fillSoundBuffer((Xout?0xff:0x00));
}