bool BassBoosterEffect::processAudioBuffer( sampleFrame* buf, const fpp_t frames ) { if( !isEnabled() || !isRunning () ) { return( false ); } // check out changed controls if( m_frequencyChangeNeeded || m_bbControls.m_freqModel.isValueChanged() ) { changeFrequency(); m_frequencyChangeNeeded = false; } if( m_bbControls.m_gainModel.isValueChanged() ) { changeGain(); } if( m_bbControls.m_ratioModel.isValueChanged() ) { changeRatio(); } float gain = m_bbControls.m_gainModel.value(); ValueBuffer *gainBuffer = m_bbControls.m_gainModel.valueBuffer(); int gainInc = gainBuffer ? 1 : 0; float *gainPtr = gainBuffer ? &( gainBuffer->values()[ 0 ] ) : &gain; double outSum = 0.0; const float d = dryLevel(); const float w = wetLevel(); if( gainBuffer ) { //process period using sample exact data for( fpp_t f = 0; f < frames; ++f ) { m_bbFX.leftFX().setGain( *gainPtr ); m_bbFX.rightFX().setGain( *gainPtr ); outSum += buf[f][0]*buf[f][0] + buf[f][1]*buf[f][1]; sample_t s[2] = { buf[f][0], buf[f][1] }; m_bbFX.nextSample( s[0], s[1] ); buf[f][0] = d * buf[f][0] + w * s[0]; buf[f][1] = d * buf[f][1] + w * s[1]; gainPtr += gainInc; } } else { //process period without sample exact data m_bbFX.leftFX().setGain( *gainPtr ); m_bbFX.rightFX().setGain( *gainPtr ); for( fpp_t f = 0; f < frames; ++f ) { outSum += buf[f][0]*buf[f][0] + buf[f][1]*buf[f][1]; sample_t s[2] = { buf[f][0], buf[f][1] }; m_bbFX.nextSample( s[0], s[1] ); buf[f][0] = d * buf[f][0] + w * s[0]; buf[f][1] = d * buf[f][1] + w * s[1]; } } checkGate( outSum / frames ); return isRunning(); }
GLWidget::GLWidget(QWidget *parent) : QGLWidget(parent), timer(new QBasicTimer) { setAttribute(Qt::WA_PaintOnScreen); setAttribute(Qt::WA_NoSystemBackground); setAutoBufferSwap(false); model = new Model(Sbs2Common::getRootAppPath() + QString("vertface_brain_reduced.obj")); sourceRecOn = 0; dragX = dragY = 0; gyroX = gyroY = 0; dragging = 0; logoPixmap.load(":/dtu.jpg"); infoPressed = 0; resetFreqs(); changeFrequency("alpha"); headMovementOn = 1; zeroRotation = 1; infoText = "looking for device..."; devicePresent = 0; dataFlowing = 0; }
BassBoosterControls::BassBoosterControls( BassBoosterEffect* effect ) : EffectControls( effect ), m_effect( effect ), m_freqModel( 100.0f, 50.0f, 200.0f, 1.0f, this, tr( "Frequency" ) ), m_gainModel( 1.0f, 0.1f, 5.0f, 0.05f, this, tr( "Gain" ) ), m_ratioModel( 2.0f, 0.1f, 10.0f, 0.1f, this, tr( "Ratio" ) ) { connect( engine::mixer(), SIGNAL( sampleRateChanged() ), this, SLOT( changeFrequency() ) ); }
BassBoosterEffect::BassBoosterEffect( Model* parent, const Descriptor::SubPluginFeatures::Key* key ) : Effect( &bassbooster_plugin_descriptor, parent, key ), m_frequencyChangeNeeded( false ), m_bbFX( DspEffectLibrary::FastBassBoost( 70.0f, 1.0f, 2.8f ) ), m_bbControls( this ) { changeFrequency(); changeGain(); changeRatio(); }
void FreqSet(unsigned int value){ if(value == 7){ changeFrequency(50000); } else if(value == 2){ changeFrequency(20000); } else if(value ==3){ changeFrequency(25000); } else if(value == 4){ changeFrequency(30000); } else if(value == 5){ changeFrequency(35000); } else if(value == 6){ changeFrequency(40000); } }
void GLWidget::mousePressEvent(QMouseEvent* event) { if (event->button() == Qt::LeftButton) { #ifdef Q_OS_MAC #else if (quitRect.contains(event->pos())) QApplication::quit(); #endif if (rotationRect.contains(event->pos())) { if (!headMovementOn) { headMovementOn = 1; zeroRotation = 0; } else if (headMovementOn && !zeroRotation) { headMovementOn = 1; zeroRotation = 1; } else if (headMovementOn && zeroRotation) { headMovementOn = 0; zeroRotation = 0; } } if (toggleRect.contains(event->pos())) { if (sourceRecOn) { } else { sourceRecOn = 1; setInfoText("loading..."); this->updateGL(); #ifdef Q_WS_MAEMO_5 emit turnSourceReconstructionPowerOn(128,32,8*1,8*60, "emotiv"); #else emit turnSourceReconstructionPowerOn(64,2,8*1,8*30, QString("emocap")); #endif } } /* if (toggleRectEmocap.contains(event->pos())) { if (sourceRecOn) { } else { sourceRecOn = 1; #ifdef Q_WS_MAEMO_5 emit turnSourceReconstructionPowerOn(128,32,8*1,8*60, "emocap"); #else emit turnSourceReconstructionPowerOn(128,16,8*1,8*30, QString("emocap")); #endif } } */ if (deltaRect.contains(event->pos())) changeFrequency("delta"); if (thetaRect.contains(event->pos())) changeFrequency("theta"); if (alphaRect.contains(event->pos())) changeFrequency("alpha"); if (lowBetaRect.contains(event->pos())) changeFrequency("lowBeta"); if (betaRect.contains(event->pos())) changeFrequency("beta"); if (logoRect.contains(event->pos())) infoPressed = !infoPressed; else if (infoRect.contains(event->pos())) infoPressed = 0; dragLastPosition = dragStartPosition = event->pos(); } }
void *governor_function(void *arg) { unsigned q0_val; unsigned q1_val; unsigned q2_val; unsigned q3_val; unsigned long q0_val_old; unsigned long q1_val_old; unsigned long q2_val_old; unsigned long q3_val_old; unsigned long b0; unsigned long b1; unsigned long b2; unsigned long b3; double overall; unsigned short first=1; struct struct_thread *param_thread; double interval; double bytes; param_thread = (struct struct_thread *)arg; short int frequency = 100; short int hold_frequency = 100; while(1) { readReg(&(param_thread->nf2), MAC_GRP_0_RX_QUEUE_NUM_BYTES_PUSHED_REG, &q0_val); readReg(&(param_thread->nf2), MAC_GRP_1_RX_QUEUE_NUM_BYTES_PUSHED_REG, &q1_val); readReg(&(param_thread->nf2), MAC_GRP_2_RX_QUEUE_NUM_BYTES_PUSHED_REG, &q2_val); readReg(&(param_thread->nf2), MAC_GRP_3_RX_QUEUE_NUM_BYTES_PUSHED_REG, &q3_val); if(!first) { setLocalBitrate(q0_val,q0_val_old,&b0); setLocalBitrate(q1_val,q1_val_old,&b1); setLocalBitrate(q2_val,q2_val_old,&b2); setLocalBitrate(q3_val,q3_val_old,&b3); interval = (double )MICROSECONDS_TO_SLEEP / 1000000; bytes = (double) (b0 + b1 + b2 + b3); overall = (bytes * 8) / interval; if(overall <= param_thread->th1) { frequency = 0; } else { frequency = 1; } //printf("\n\n\n\nthresho bitrate:%ld\n\n",param_thread->th1); //printf("\noverall bitrate:%f\n\n",overall); if(hold_frequency != frequency) { //printf("q0:%lu\n",q0_val); //printf("bitrate in q0:%lu bps\n",b0); //printf("q1:%lu\n",q1_val); //printf("bitrate in q1:%lu bps\n",b1); //printf("q2:%lu\n",q2_val); //printf("bitrate in q2:%lu bps\n",b2); //printf("q3:%lu\n",q3_val); //printf("bitrate in q3:%lu bps\n",b3); //printf("overall bitrate:%lf\n\n",overall); //printf("-------------------\n"); //printf("Frequency: %d\n", frequency); //printf("-------------------\n"); if(hold_frequency != 0 && frequency == 0) {// From 125 MHz to 62.5 MHz int random_num = rand()%100; if(random_num > pg) { hold_frequency = frequency; changeFrequency(param_thread, frequency); } } else { // From 62.5 MHz to 125 MHz hold_frequency = frequency; changeFrequency(param_thread, frequency); } //hold_frequency = frequency; //changeFrequency(param_thread, frequency); usleep(2000); } } else { first = 0; } q0_val_old = q0_val; q1_val_old = q1_val; q2_val_old = q2_val; q3_val_old = q3_val; usleep(param_thread->microseconds_to_sleep); } }
int main() { char freq0Disp[16], freq1Disp[16]; char usbRx[USBUART_BUFFER_SIZE], usbTx[USBUART_BUFFER_SIZE]; /* Initializes the LCD. */ LCD_Start(); LCD_Position(1u,0u); LCD_Position(0u,0u); LCD_PrintString("F1="); WaveDAC_0_Clock_Start(); WaveDAC_1_Clock_Start(); // Needed for WaveDACs to operate concurrently // I think this might be a bug with PSoC WaveDAC_0_Start(); WaveDAC_1_Start(); WaveDAC_0_Stop(); WaveDAC_1_Stop(); USBUART_Start(USBFS_DEVICE, USBUART_5V_OPERATION); USBUART_CDC_Init(); CyGlobalIntEnable; while (1) { if (USBUART_IsConfigurationChanged()) { if (USBUART_GetConfiguration()) { USBUART_CDC_Init(); } } if (USBUART_GetConfiguration()) { if (USBUART_DataIsReady()) { int numArgs; int desiredFreq, newFreq, fnGenerator; char mode[USBUART_BUFFER_SIZE] = {0}; Serial_GetString(usbRx); trimString(usbRx); numArgs = sscanf(usbRx, "%d %s %d", &fnGenerator, mode, &desiredFreq); if (numArgs == 3) { if (!strcmp(mode, "square")) { newFreq = changeFrequency(desiredFreq, SQUARE, fnGenerator); sprintf(usbTx, "fn = %d, mode = %s, newFreq = %d\r\n", fnGenerator, mode, newFreq); } else if (!strcmp(mode, "sine")) { newFreq = changeFrequency(desiredFreq, SINE, fnGenerator); sprintf(usbTx, "fn = %d, mode = %s, newFreq = %d\r\n", fnGenerator, mode, newFreq); } else if (!strcmp(mode, "triangle")) { newFreq = changeFrequency(desiredFreq, TRIANGLE, fnGenerator); sprintf(usbTx, "fn = %d, mode = %s, newFreq = %d\r\n", fnGenerator, mode, newFreq); } else if (!strcmp(mode, "sawtooth")) { newFreq = changeFrequency(desiredFreq, SAWTOOTH, fnGenerator); sprintf(usbTx, "fn = %d, mode = %s, newFreq = %d\r\n", fnGenerator, mode, newFreq); } else if (!strcmp(mode, "dc")) { newFreq = changeFrequency(desiredFreq, DC, fnGenerator); sprintf(usbTx, "fn = %d, mode = %s, newFreq = %d\r\n", fnGenerator, mode, newFreq); } else { sprintf(usbTx, "Invalid mode: %s\r\n", mode); } } else if (numArgs == 2) { if (!strcmp(mode, "off")) { if (fnGenerator == 0) { stopWaveDac(WAVEDAC_LOW_0); } else if (fnGenerator == 1) { stopWaveDac(WAVEDAC_LOW_1); } sprintf(usbTx, "Stopped WaveDAC %d\r\n", fnGenerator); } else { sprintf(usbTx, "Invalid mode: %s\r\n", mode); } } else { sprintf(usbTx, "Invalid command: %s\r\n", usbRx); } Serial_PutString(usbTx); } } } }