From 0d787bc6133900527a7d0a4cbadc3d5a9d344cef Mon Sep 17 00:00:00 2001 From: Oliver Schinagl Date: Tue, 18 Jan 2005 15:59:15 +0000 Subject: Added internal audio play functionality. --- Graphic_Equalizer/src/audio.hcc | 99 ++++++++++++++++++++++++++--------------- 1 file changed, 63 insertions(+), 36 deletions(-) diff --git a/Graphic_Equalizer/src/audio.hcc b/Graphic_Equalizer/src/audio.hcc index 2a65700..8722ce7 100644 --- a/Graphic_Equalizer/src/audio.hcc +++ b/Graphic_Equalizer/src/audio.hcc @@ -19,9 +19,12 @@ #include "pal_master.hch" #include "configuration.hch" +#include "smartmedia_shared.hch" +#include "display_shared.hch" #if USE_RUNFFT #include "audio.hch" #include "fft.hch" +#include "smartmedia.hch" #endif #if HAVE_DEBUG #include "debug.hch" @@ -62,7 +65,6 @@ signed 16 *audioptr_out1,*audioptr_out2; unsigned 6 *displayptr1,*displayptr2,*displayptr3,*displayptr4; #endif -unsigned 6 sample_count; unsigned 1 FFT_Sync; signed Output_sample; @@ -180,7 +182,7 @@ macro proc audio_main(audiodata, AUDIOIN, AUDIOOUT) macro proc run_fft(audiodata) { - for(;;) + while(TRUE) { if (FFT_Sync) //if 64 samples are read from ADC... { @@ -200,9 +202,10 @@ macro proc run_fft(audiodata) displayptr3=displayptr4; displayptr4=displayptr1; - FFT_Sync = 0; + } + FFT_Sync = 0; // FFT calculation perform_fft(audioptr_in1); @@ -232,55 +235,79 @@ macro proc sample_audio(audiodata, AUDIOOIN) macro expr IW = PalAudioInGetMaxDataWidthCT(); signed IW LeftNew, RightNew; + unsigned 27 blockcount; unsigned 8 not_saturated; + unsigned 6 sample_count; unsigned 2 saturation; + unsigned 1 result; - for(sample_count=0;;)//store the samples in the inputbuffer - { - if (!FFT_Sync) + par { + while (TRUE) { - par + if (FFT_Sync && audiodata.play) //if 64 samples are read from ... + { + result = load_audio_samples(audioptr_in1, blockcount, WINDOW_SIZE); + if (result) { + blockcount = 0; + } else { + blockcount++; + } + } + else + { + delay; + } + } + while (TRUE)//store the samples in the inputbuffer + { + if (!FFT_Sync) { - seq + par { - PalAudioInRead(AUDIOIN, &LeftNew, &RightNew); + seq + { + PalAudioInRead(AUDIOIN, &LeftNew, &RightNew); + + if (!audiodata.play) + { #if HARDWARE_MULTIPLY - audioptr_in1[sample_count] = LeftNew; + audioptr_in1[sample_count] = LeftNew; #else - audioptr_in1[sample_count] = (LeftNew\\2);//drop 2 LSB's + audioptr_in1[sample_count] = (LeftNew\\2);//drop 2 LSB's #endif - if (LeftNew > 130000) { - saturation++; - if (!saturation) { - audiodata.saturated = TRUE; - event_notification ! TRUE; - } else { - audiodata.saturated = FALSE; + if (LeftNew > 130000) { + saturation++; + if (!saturation) { + audiodata.saturated = TRUE; + event_notification ! TRUE; + } else { + audiodata.saturated = FALSE; + } + } else { + not_saturated++; + if (!not_saturated) { + audiodata.saturated = FALSE; + saturation = 0; + event_notification ! TRUE; + } + } } - } else { - not_saturated++; - if (!not_saturated) { - audiodata.saturated = FALSE; - saturation = 0; - event_notification ! TRUE; + sample_count++; + if (!sample_count) + { + FFT_Sync = TRUE; } } - - sample_count++; - if (!sample_count) + seq { - FFT_Sync = 1; + Output_sample = audioptr_out2[sample_count]; } } - seq - { - Output_sample = audioptr_out2[sample_count]; - } } - } - else - { - delay; + else + { + delay; + } } } }/* --- sample_audio() --- */ -- cgit v0.12