Digital Signal Processing Reference
In-Depth Information
else{HarmBool=1; iHarm++; //or just switch the count
if(iHarm>HarmLength) iHarm=0;} //and increment the pointer
output=input+HarmAmp*0.0125*HarmBuffer[jHarm];//add harmonics to output
jHarm++;
//and increment the pointer
if(jHarm>HarmLength) jHarm=0;
//reinit when maxed out
DrumDelay--;
//decrement delay counter
if(DrumDelay<1) {
//drum section
DrumDelay=50000-Tempo;
//if time for drumbeat
DrumOn=1;
//turn it on
}
if(0){ //if drum is on
output=output+(kick[iDrum])*.05*(ampDrum);//play next sample
if((sDrum%2)==1) {iDrum++;}
//but play at Fs/2
sDrum++;
//incr sample number
if(iDrum>2500){iDrum=0; DrumOn=0;}
//drum off if last sample
}
output = output*.0001*VolSlider*VolSlider;
AIC23_data.channel[LEFT]=output;
AIC23_data.channel[RIGHT]=AIC23_data.channel[LEFT];
output_sample(AIC23_data.uint);
//output to both channels
}
main() //init DSK,codec,McBSP and while(1) infinite loop
FIGURE 10.17. ( Continued )
The third effect is harmonics boost. A harmonics buffer is used for this effect.
Two main loop sections are created to produce two separate sets of harmonics. The
larger (outer) loop combines the input with samples from the harmonics buffer at
twice the input frequency. The smaller (inner) loop produces the next harmonics at
four times the input frequency. The magnitudes of the harmonics are controlled with
a slider.
These effects were tested successfully using the input from a keyboard with the
keyboard output to a speaker. The audio output is sent to both channels of the codec
(see Example 2.3), using the stereo capability of the onboard codec. The executable
and gel files are included in the folder soundboard .
A drum effect section is included in the program for expanding the project. The
use of external memory must be considered when applying many effects.
10.10 VOICE DETECTION AND REVERSE PLAYBACK
This project detects a voice signal from a microphone, then plays it back in
the reverse direction. Figure 10.18 shows the block diagram that implements this
project. All the necessary files are in the folder detect_play. Two circular buffers
are used: an input buffer to hold 80,000 samples (10 seconds of data) continuously
being updated and an output buffer to play back the input voice signal in the reverse
direction. The signal level is monitored, and its envelope is tracked to determine
whether or not a voice signal is present.
Search WWH ::




Custom Search