📄 output.c
字号:
// return(sOutput.pOutputBuffer);}//****************************************************************************//// OutputSetFormat sets the sample rate and number of channels of the input// data stream.////****************************************************************************unsigned longOutputSetFormat(long lSampleRate, long lChannels){ BufferState *psBuffer; long lBaseRate; // // If the output processing interrupt is currently enabled, then turn it // off and wait for the output buffer to drain. // if(ulSystemFlags & SYSFLAG_PROCESS_OUTPUT) { // // Turn off the output processing interrupt. // DisableIRQ(); ulSystemFlags &= ~SYSFLAG_PROCESS_OUTPUT; EnableIRQ(); // // Wait until the the digital audio interface has completed playback. // psBuffer = DAIGetPlayBuffer(); while(!BufferIsEmpty(psBuffer)) { // // Put the EP7209 into HALT mode. // Halt(); } } // // Determine the base rate at which to run the digital audio interface. // switch(lSampleRate) { // // 8000Hz, 16000Hz, and 32000Hz are played back at a base rate of // 32000Hz. // case 8000: case 16000: case 32000: { // // The base rate is 32000Hz. // lBaseRate = 32000; // // We're done with these rates. // break; } // // 11025Hz, 22050Hz, and 44100Hz are played back at a base rate of // 44100Hz. // case 11025: case 22050: case 44100: { // // The base rate is 44100Hz. // lBaseRate = 44100; // // We're done with these rates. // break; } // // 12000Hz, 24000Hz, and 48000Hz are played back at a base rate of // 48000Hz. // case 12000: case 24000: case 48000: { // // The base rate is 48000Hz. // lBaseRate = 48000; // // We're done with these rates. // break; } // // We assume a base rate of 44100Hz for all other sample rates. // default: { // // The base rate is 44100Hz. // lBaseRate = 44100; // // We're done with this rate. // break; } } // // Set the sample rate of the base rate buffer. // if(BufferSetSampleRate(sOutput.pBaseRateBuffer, lBaseRate, lSampleRate) == 0) { // // We could not set the sample rate to the given base rate, so assume // a base rate of 44100Hz. // lBaseRate = 44100; // // Set the sample rate of the base rate buffer. // BufferSetSampleRate(sOutput.pBaseRateBuffer, lBaseRate, lSampleRate); } // // See if the sample rate is the base rate. // if(lSampleRate == lBaseRate) { // // Since the sample rate is the base rate, we do not need to perform a // sample rate conversion. Therefore, our output buffer is the base // rate input buffer. // sOutput.pOutputBuffer = sOutput.pBaseRateBuffer; } else { // // The sample rate is not the base rate, so initialize the sample rate // converter. // if(SRCInit(&(sOutput.sSRC), lSampleRate, lBaseRate) == 0) { // // We could not initialize the sample rate converter, so return an // error. // return(0); } // // Our output buffer is the sample rate converter's input buffer. // sOutput.pOutputBuffer = SRCGetInputBuffer(&(sOutput.sSRC)); // // Set the buffer for the output from the SRC. // if(lChannels == 2) { BufferSetBuffer(sOutput.pBaseRateBuffer, sOutput.sOutputLeft, sOutput.sOutputRight, 384); } else { BufferSetBuffer(sOutput.pBaseRateBuffer, sOutput.sOutputLeft, sOutput.sOutputLeft, 384); } // // If the output is enabled, then we need to enable the output // processing interrupt. // if(ulSystemFlags & SYSFLAG_OUTPUT_ENABLED) { DisableIRQ(); ulSystemFlags |= SYSFLAG_PROCESS_OUTPUT; EnableIRQ(); } } // // Success. // return(1);}//****************************************************************************//// OutputSetTone adjusts the tone controls.////****************************************************************************voidOutputSetTone(long lTreble, long lBass, long lGain){#ifdef SOFTWARE_TONE_CONTROL // // Disable the IRQ interrupt. // DisableIRQ(); // // Adjust the tone controls. // ToneAdjust(&(sOutput.sTone), lTreble, lBass, lGain); // // Re-enable the IRQ interrupt. // EnableIRQ();#endif#ifdef ADDR_CS43L43 // // If the treble boost is out of range, then adjust it. // if(lTreble < 0) { lTreble = 0; } else if(lTreble > 12) { lTreble = 12; } // // If the bass boost is out of range, then adjust it. // if(lBass < 0) { lBass = 0; } else if(lBass > 12) { lBass = 0; } // // Remember the new treble and bass boost settings. // sOutput.cTrebleBoost = lTreble; sOutput.cBassBoost = lBass; // // If the output is enabled, then write this new settings immediately. // if(ulSystemFlags & SYSFLAG_OUTPUT_ENABLED) { TwoWireWrite((unsigned long *)(HwBaseAddress + HwPortABCD), (unsigned long *)(HwBaseAddress + HwDdrABCD), HwPortABCD_Clock, HwPortABCD_Data, ADDR_CS43L43, 0x06, (sOutput.cBassBoost << 4) | sOutput.cTrebleBoost); }#endif}//****************************************************************************//// OutputSetTreble adjusts the treble tone control.////****************************************************************************voidOutputSetTreble(long lTreble){#ifdef SOFTWARE_TONE_CONTROL // // Adjust the treble control. // ToneAdjustTreble(&(sOutput.sTone), lTreble);#endif#ifdef ADDR_CS43L43 // // If the treble boost is out of range, then adjust it. // if(lTreble < 0) { lTreble = 0; } else if(lTreble > 12) { lTreble = 12; } // // Remember the new treble boost setting. // sOutput.cTrebleBoost = lTreble; // // If the output is enabled, then write this new settings immediately. // if(ulSystemFlags & SYSFLAG_OUTPUT_ENABLED) { TwoWireWrite((unsigned long *)(HwBaseAddress + HwPortABCD), (unsigned long *)(HwBaseAddress + HwDdrABCD), HwPortABCD_Clock, HwPortABCD_Data, ADDR_CS43L43, 0x06, (sOutput.cBassBoost << 4) | sOutput.cTrebleBoost); }#endif}//****************************************************************************//// OutputSetBass adjusts the bass tone control.////****************************************************************************voidOutputSetBass(long lBass){#ifdef SOFTWARE_TONE_CONTROL // // Adjust the bass control. // ToneAdjustBass(&(sOutput.sTone), lBass);#endif#ifdef ADDR_CS43L43 // // If the bass boost is out of range, then adjust it. // if(lBass < 0) { lBass = 0; } else if(lBass > 12) { lBass = 0; } // // Remember the new bass boost setting. // sOutput.cBassBoost = lBass; // // If the output is enabled, then write this new settings immediately. // if(ulSystemFlags & SYSFLAG_OUTPUT_ENABLED) { TwoWireWrite((unsigned long *)(HwBaseAddress + HwPortABCD), (unsigned long *)(HwBaseAddress + HwDdrABCD), HwPortABCD_Clock, HwPortABCD_Data, ADDR_CS43L43, 0x06, (sOutput.cBassBoost << 4) | sOutput.cTrebleBoost); }#endif}//****************************************************************************//// OutputSetGain adjusts the gain control.////****************************************************************************voidOutputSetGain(long lGain){#ifdef SOFTWARE_TONE_CONTROL // // Adjust the gain control. // ToneAdjustGain(&(sOutput.sTone), lGain);#endif}//****************************************************************************//// OutputToneEnable enables the software tone control.////****************************************************************************#ifdef SOFTWARE_TONE_CONTROLvoidOutputToneEnable(void){ // // Enable the tone control. // ToneEnable(&(sOutput.sTone));}#endif//****************************************************************************//// OutputToneDisable disables the software tone control.////****************************************************************************#ifdef SOFTWARE_TONE_CONTROLvoidOutputToneDisable(void){ // // Disable the tone control. // ToneDisable(&(sOutput.sTone));}#endif//****************************************************************************//// OutputSetVolume adjusts the volume control.////****************************************************************************voidOutputSetVolume(long lGain){#ifdef SOFTWARE_VOLUME_CONTROL // // Adjust the volume control. // VolumeAdjust(&(sOutput.sVolume), lGain);#endif#ifdef ADDR_CS43L43 // // If the volume setting is out of range, then adjust it. // if(lGain < 0) { lGain = 0; } else if(lGain > 20) { lGain = 20;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -