Rory Hand / Mbed 2 deprecated NotchingDemo

Dependencies:   mbed SDFileSystem_Copy_of_mbed_version I2S

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers NotchingDemo.cpp Source File

NotchingDemo.cpp

00001 
00002 //  24/03/2018  update - I appear to be able to address the device and write something, as I am getting an ACK returned from the i2c write() function.
00003 //however if i use the write function with 4 arguments (as opposed to just 1 argument) then it doesnt work
00004 //only works with the 1 argument version!!!
00005 
00006 
00007 //THIS VERSION WORKED, CHANGED SOME THINGS, THEN CHANGED THEM BACK.  NOW IT NO LONGER WORKS!!!!
00008 #include "mbed.h"
00009 #include "math.h"
00010 #include "I2S.h"
00011 #include "SDFileSystem.h"
00012 #include "wm8731_Config_setup.h"
00013 #include "WOLFSON_config_consts.h"
00014 //#include "BlockDevice.h"
00015 #include <string>
00016 #include <stdlib.h>
00017 #include <fstream>
00018 #include <iostream>
00019 #include <vector>
00020 #include <string>
00021 #define sample_freq 11025
00022 //#pragma import __use_two_region_memory
00023 //BlockDevice *bd = BlockDevice::get_default_instance();
00024 //#include "LittleFileSystem.h"
00025 //LittleFileSystem fs("fs");
00026 
00027 DigitalOut myled(LED1);
00028 DigitalOut led2(LED2);
00029 DigitalOut led3(LED3);
00030 DigitalIn  NotchUp(p16);
00031 DigitalIn  NotchDown(p17);//check the pin!!! Dont know if this will actually work...
00032 InterruptIn Horn(p16);
00033 Ticker sampletick;
00034 Ticker NotchUpTick;
00035 
00036 Ticker TickFadeOut;
00037 Timer t;
00038 Timer t2;
00039 Timer OperationsTimer;
00040 Timer NotchTimer;
00041 Timer timer_open;
00042 
00043 Serial pc(USBTX, USBRX); // tx, rx //FOR DEBUGGING PROGRAM USING GNU SCREEN
00044 DigitalOut cs(p8);
00045 I2S i2s(I2S_TRANSMIT, p5, p6, p7);
00046 SDFileSystem sd(p11, p12, p13, p8, "sd"); // the new pinout that i am using
00047 
00048 class classFade
00049 {
00050 public:
00051 
00052     float powerval;
00053     float FadeIteration;
00054     float DecayFactor;
00055     float Denom;
00056     float FadeCoeff;
00057     float Natural_Exp;
00058     int LengthSecs;
00059     int Length;
00060     void FadeDataInitialise()
00061     {
00062         DecayFactor = 1.3;
00063         FadeIteration = 1;
00064         //FadeData.Denom = 11025*FadeData.DecayFactor;
00065         Denom = 11025*DecayFactor;
00066         Natural_Exp = 2.7183;
00067         Length = 11025*LengthSecs;
00068         //FadeData.Natural_Exp = 2.7;
00069     }
00070     //member Functions
00071     float FadeOut(void)
00072     {
00073         powerval = -FadeIteration/Denom;
00074         if (FadeIteration >=Length) {
00075             FadeCoeff = 0;
00076 
00077         } else {
00078             FadeCoeff = (Length - FadeIteration)/Length;
00079         }
00080         FadeIteration = FadeIteration + 1;
00081         return FadeCoeff;
00082 
00083     }
00084     float FadeIn(void)
00085     {
00086         powerval = FadeIteration/Denom;
00087         if (FadeIteration >=Length) {
00088             FadeCoeff = 1;
00089 
00090         } else {
00091             FadeCoeff = FadeIteration/Length;
00092         }
00093 
00094         FadeIteration = FadeIteration + 1;
00095         return FadeCoeff;
00096 
00097     }
00098 };
00099 
00100 
00101 //Do these variables have to be global??  Find out - may be better (safer) to make them local.
00102 classFade NotchFadeIn;
00103 classFade NotchFadeOut;
00104 
00105 
00106 //Dont require the class below.  Turns out I had already made a Structure to hold the same information.
00107 //If in the futre I need to embed functions then I will switch to using this class
00108 
00109 
00110 typedef struct uFMT_STRUCT {
00111     short comp_code;
00112     short num_channels;
00113     unsigned sample_rate;
00114     unsigned avg_Bps;
00115     short block_align;
00116     short sig_bps;
00117 } FMT_STRUCT;
00118 
00119 typedef struct uNotch_STRUCT {
00120     short Notch;
00121     short NotchTransUp;
00122     short NotchTransDown;
00123     short NotchDirection;
00124 } Notch_STRUCT;
00125 
00126 Notch_STRUCT NotchingSet;
00127 
00128 
00129 typedef struct uDATA_STRUCT {
00130     unsigned subchunk2_ID;
00131     unsigned subchunk2_size;
00132     char * data_buf;
00133 } DATA_STRUCT;
00134 
00135 typedef struct uWAV_FILE_STRUCT {
00136     FILE *WavFile;
00137     int id_number;
00138     char *slice_buf;
00139     int num_slices;
00140     FMT_STRUCT  FileFormat;
00141     DATA_STRUCT FileData;
00142 } WAV_FILE_STRUCT;
00143 
00144 /*typedef struct uWAV_FILE_STRUCT{
00145     FILE* WavFile;
00146 
00147 
00148 }WAV_FILE_STRUCT;*/
00149 
00150 
00151 
00152 
00153 
00154 class classSoundFile
00155 {
00156 public:
00157 
00158 //add a class constructor at some point in the future (perform tests in visual studio)
00159     WAV_FILE_STRUCT FileInfo;
00160     short * data_sptr;
00161     string file_location;
00162     //classSoundFile(string filename);//this is the constructor
00163     //string filename;
00164 };
00165 class classPositionIndicators
00166 {
00167 public:
00168     int notch1_indicator, notch2_indicator, notch3_indicator, notch4_indicator;
00169     int notch5_indicator, notch6_indicator, notch7_indicator, notch8_indicator;
00170     int notch1_start_pt, notch2_start_pt, notch3_start_pt, notch4_start_pt;
00171     int notch5_start_pt, notch6_start_pt, notch7_start_pt, notch8_start_pt;
00172     int N1N2_start_pt, N2N3_start_pt, N3N4_start_pt, N4N5_start_pt, N5N6_start_pt;
00173     int N6N7_start_pt, N7N8_start_pt, N8N7_start_pt, N7N6_start_pt, N6N5_start_pt;
00174     int N5N4_start_pt, N4N3_start_pt, N3N2_start_pt, N2N1_start_pt;
00175 
00176     int notch_start_pts [9];
00177     int notch_position_indicators[9];
00178     int notch_transitions_start_pts[15];
00179     int notch_transitions_position_indicators[15];
00180     int auxiliary_start_pts[5];
00181     int auxiliary_position_indicators[5];
00182     classPositionIndicators()
00183     {
00184         notch1_start_pt = 44;
00185         notch2_start_pt = 220884+44;
00186         notch3_start_pt = notch2_start_pt+217698;
00187         notch4_start_pt = notch3_start_pt + 193060;
00188         notch5_start_pt = notch4_start_pt + 92010;
00189         notch6_start_pt = notch5_start_pt + 216642;
00190         notch7_start_pt = notch6_start_pt + 250316;
00191         notch8_start_pt = notch7_start_pt + 150152;
00192         notch1_indicator = notch1_start_pt;
00193         notch2_indicator = notch2_start_pt;
00194         notch3_indicator = notch3_start_pt;
00195         notch4_indicator = notch4_start_pt;
00196         notch5_indicator = notch5_start_pt;
00197         notch6_indicator = notch6_start_pt;
00198         notch7_indicator = notch7_start_pt;
00199         notch8_indicator = notch8_start_pt;
00200         notch_start_pts[1] = notch1_start_pt;
00201         notch_start_pts[2] = notch2_start_pt;
00202         notch_start_pts[3] = notch3_start_pt;
00203         notch_start_pts[4] = notch4_start_pt;
00204         notch_start_pts[5] = notch5_start_pt;
00205         notch_start_pts[6] = notch6_start_pt;
00206         notch_start_pts[7] = notch7_start_pt;
00207         notch_start_pts[8] = notch8_start_pt;
00208         notch_position_indicators[1] = notch1_indicator;
00209         notch_position_indicators[2] = notch2_indicator;
00210         notch_position_indicators[3] = notch3_indicator;
00211         notch_position_indicators[4] = notch4_indicator;
00212         notch_position_indicators[5] = notch5_indicator;
00213         notch_position_indicators[6] = notch6_indicator;
00214         notch_position_indicators[7] = notch7_indicator;
00215         notch_position_indicators[8] = notch8_indicator;
00216 
00217         N1N2_start_pt = 44;
00218         N2N3_start_pt = N1N2_start_pt + 73220;
00219         N3N4_start_pt = N2N3_start_pt + 78164;
00220         N4N5_start_pt = N3N4_start_pt + 59432;
00221         N5N6_start_pt = N4N5_start_pt + 64984;
00222         N6N7_start_pt = N5N6_start_pt + 59924;
00223         N7N8_start_pt = N6N7_start_pt + 97874;
00224         N8N7_start_pt = N7N8_start_pt + 63992;
00225         N7N6_start_pt = N8N7_start_pt + 44506;
00226         N6N5_start_pt = N7N6_start_pt + 55052;
00227         N5N4_start_pt = N6N5_start_pt + 37038;
00228         N4N3_start_pt = N5N4_start_pt + 49692;
00229         N3N2_start_pt = N4N3_start_pt + 44100;
00230         N2N1_start_pt = N3N2_start_pt + 58346;
00231 
00232 
00233         notch_transitions_start_pts[1] = N1N2_start_pt;
00234         notch_transitions_start_pts[2] = N2N3_start_pt;
00235         notch_transitions_start_pts[3] = N3N4_start_pt;
00236         notch_transitions_start_pts[4] = N4N5_start_pt;
00237         notch_transitions_start_pts[5] = N5N6_start_pt;
00238         notch_transitions_start_pts[6] = N6N7_start_pt;
00239         notch_transitions_start_pts[7] = N7N8_start_pt;
00240         notch_transitions_start_pts[8] = N8N7_start_pt;
00241         notch_transitions_start_pts[9] = N7N6_start_pt;
00242         notch_transitions_start_pts[10] = N6N5_start_pt;
00243         notch_transitions_start_pts[11] = N5N4_start_pt;
00244         notch_transitions_start_pts[12] = N4N3_start_pt;
00245         notch_transitions_start_pts[13] = N3N2_start_pt;
00246         notch_transitions_start_pts[14] = N2N1_start_pt;
00247 
00248 
00249         notch_transitions_position_indicators[1] = N1N2_start_pt;
00250         notch_transitions_position_indicators[2] = N2N3_start_pt;
00251         notch_transitions_position_indicators[3] = N3N4_start_pt;
00252         notch_transitions_position_indicators[4] = N4N5_start_pt;
00253         notch_transitions_position_indicators[5] = N5N6_start_pt;
00254         notch_transitions_position_indicators[6] = N6N7_start_pt;
00255         notch_transitions_position_indicators[7] = N7N8_start_pt;
00256         notch_transitions_position_indicators[8] = N8N7_start_pt;
00257         notch_transitions_position_indicators[9] = N7N6_start_pt;
00258         notch_transitions_position_indicators[10] = N6N5_start_pt;
00259         notch_transitions_position_indicators[11] = N5N4_start_pt;
00260         notch_transitions_position_indicators[12] = N4N3_start_pt;
00261         notch_transitions_position_indicators[13] = N3N2_start_pt;
00262         notch_transitions_position_indicators[14] = N2N1_start_pt;
00263     }
00264 };
00265 
00266 int TransitionFlag;
00267 void NotchUpIsr()
00268 {
00269     if(1 <= NotchingSet.Notch < 8) {
00270 
00271         NotchingSet.Notch = NotchingSet.Notch + 1;
00272         NotchingSet.NotchTransUp = NotchingSet.Notch + 7;
00273         NotchingSet.NotchDirection = 1;
00274         NotchFadeIn.FadeDataInitialise();
00275         NotchFadeOut.FadeDataInitialise();
00276         TransitionFlag = 1;
00277         //printf("We are in the NotchUpIsr() section \n\r");
00278         //NotchFadeOut.FadeDataInitialise;
00279     }
00280 }
00281 
00282 void NotchDownIsr()
00283 {
00284     if(1 < NotchingSet.Notch <= 8) {
00285         NotchingSet.Notch = NotchingSet.Notch - 1;
00286         NotchingSet.NotchTransDown = NotchingSet.Notch + 15;
00287         NotchingSet.NotchDirection = 0;
00288         NotchFadeIn.FadeDataInitialise();
00289         NotchFadeOut.FadeDataInitialise();
00290         TransitionFlag = 1;
00291     }
00292 }
00293 short * data_sptr1;
00294 short * data_sptr2;
00295 short * data_sptr3;
00296 char *slice_buf1;
00297 char *slice_buf2;
00298 char *slice_buf3;
00299 
00300 int OneOff = 0;
00301 int notch_flag = 0;
00302 int i = 0;
00303 int h = 0;
00304 short bufflen = 1;
00305 int buffer[1];
00306 
00307 char *slice_buf;
00308 short *data_sptr;
00309 
00310 
00311 
00312 unsigned channel;
00313 long slice, slice1, slice2, slice3, num_slices;
00314 int interrupt_condition = 1;
00315 int sampling_freq = 11025;
00316 const int BufferLen = 2000;
00317 short Buffer1[BufferLen];
00318 short Buffer2[BufferLen];
00319 short place_hold1 = 0;
00320 short place_hold2 = 0;
00321 
00322 
00323 
00324 
00325 volatile int flag1 = 1;
00326 volatile int flag2 = 0;
00327 volatile int flag3 = 1;
00328 volatile int flag4 = 0;
00329 int FLAGBUFF1 = 0;
00330 int FLAGBUFF2 = 0;
00331 int BellFlag = 0;
00332 int BellFlag2 = 0;
00333 int FadeFlag = 0;
00334 int BlockFlag = 0;
00335 
00336 
00337 
00338 short value[1];
00339 
00340 //long long slice_value;
00341 int slice_value[1];
00342 
00343 
00344 
00345 
00346 
00347 void isr()
00348 {
00349     //timer_interrupt.start();
00350     if(flag1 == 0) {
00351         value[0] = Buffer1[place_hold1]>>4;
00352         i2s.write(value,1);//Send next PWM value to amp
00353         place_hold1 = place_hold1 + 1;
00354         if( (place_hold1 >= BufferLen)) {
00355             led2  = !led2;
00356             place_hold1 = 0;
00357             place_hold2 = 0;
00358             flag1 = 1;
00359             flag2 = 0;
00360         }
00361     } else if(flag2 == 0) {
00362         value[0] = Buffer2[place_hold2]>>4;
00363         i2s.write(value,1);//Send next PWM value to amp
00364         place_hold2 = place_hold2 + 1;
00365         if( (place_hold2 >= BufferLen) ) {
00366             led2  = !led2;
00367             place_hold1 = 0;
00368             place_hold2 = 0;
00369             flag1 = 0;
00370             flag2 = 1;
00371             FLAGBUFF2 = 0;
00372         }
00373     }
00374 
00375     //timer_interrupt.stop();
00376 
00377 }
00378 
00379 
00380 
00381 
00382 
00383 
00384 
00385 
00386 
00387 
00388 
00389 
00390 
00391 
00392 
00393 
00394 //function prototypes
00395 //classFade FadeDataInitialise(classFade FadeData);
00396 classSoundFile ReadFileInfo(classSoundFile Sound, FILE * wav_file);
00397 classSoundFile LoadFileStream(classSoundFile FileInfo, string filename);
00398 void Play_WaveFile(FILE * my_wav, WAV_FILE_STRUCT FileInfo);
00399 void Play_WaveFileDual(FILE * my_wav, WAV_FILE_STRUCT FileInfo);
00400 void Play_WaveFileLoop(classSoundFile Sound1, classSoundFile Sound2, FILE* wavfile1, FILE* wavfile2,classPositionIndicators Positions);
00401 
00402 int main()
00403 {
00404 
00405     NotchUp.mode(PullUp);
00406     NotchDown.mode(PullUp);
00407 
00408     pc.printf("Beginning of program\n");
00409 
00410 
00411 
00412 
00413     printf("Do we even get to this stupid bloody point\n\r");
00414     //Populate our class instances with some data (is there an implicit way to do this?)
00415 
00416 
00417     printf("hello\n\r");
00418     //Set up the wolfson Audio Codec board
00419     
00420     
00421     wm8731_Config_setup();
00422     //i2s audio data transfer code??
00423     i2s.stereomono(I2S_STEREO);
00424     i2s.masterslave(I2S_MASTER);
00425     led3 = 1;
00426     led2 = 1;
00427     printf("Hello i2s has started!");
00428     i2s.start();
00429     sampletick.attach(&isr,1.0/sampling_freq);  //1/16000
00430     NotchUpTick.attach(&NotchUpIsr,10.0);
00431 
00432 
00433 
00434     NotchFadeIn.LengthSecs = 2;
00435     NotchFadeOut.LengthSecs = 2;
00436 
00437     NotchFadeIn.FadeDataInitialise();
00438     NotchFadeOut.FadeDataInitialise();
00439 
00440 
00441     classPositionIndicators Positions;
00442     slice1 = Positions.notch_start_pts[1];
00443     
00444     
00445     
00446     TransitionFlag = 0;
00447     
00448     FILE* wavfile1 = fopen("/sd/mydir/SoundDecoder_second/01.wav","rb");
00449     FILE* wavfile2 = fopen("/sd/mydir/SoundDecoder_second/04.wav","rb");
00450     FILE* wavfile3 = fopen("/sd/mydir/SoundDecoder_second/05.wav","rb");
00451     
00452     //FILE* wavfile1 = fopen("/sd/mydir/SoundDecoder_second/01.wav","rb");
00453     classSoundFile Sound1;
00454     classSoundFile Sound2;
00455     classSoundFile Sound4;
00456 
00457     
00458     Sound4 = ReadFileInfo(Sound4, wavfile3);
00459     Sound2 = ReadFileInfo(Sound2, wavfile2);
00460     Sound1 = ReadFileInfo(Sound1, wavfile1);
00461     printf("sizeof(Sound1): %d bytes\n\r",sizeof(Sound1));
00462     NotchingSet.Notch = 1;
00463     //Positions.notch_position_indicators[1] = 44;
00464     fseek(wavfile1,Positions.notch_start_pts[1],SEEK_SET);
00465     fseek(wavfile2,Positions.notch_transitions_start_pts[1],SEEK_SET);
00466     printf("about to play wav file\n\r");
00467     Play_WaveFileLoop(Sound1,Sound2, wavfile1,wavfile2, Positions);
00468     printf("finished playing Wav file\n\r");
00469 
00470 
00471     timer_open.reset();
00472     timer_open.start();
00473     fclose(wavfile1);
00474     timer_open.stop();
00475     printf("It took %d useconds to close file\n\r",timer_open.read_us());
00476 
00477 
00478 
00479 
00480     /************************************PLAY WAV FILE LOOP*******************/
00481     /************************************END OF PLAY WAV FILE LOOP*************/
00482 
00483 
00484     i2s.stop();
00485     
00486 
00487 }
00488 
00489 
00490 
00491 
00492 
00493 
00494 classSoundFile ReadFileInfo(classSoundFile Sound, FILE * wav_file)
00495 {
00496     fseek(wav_file,20,SEEK_SET);
00497     printf("We have just seeked through this file\n\r");
00498     fread(&Sound.FileInfo.FileFormat,sizeof(Sound.FileInfo.FileFormat),1,wav_file);
00499     //printf("wav_format.sample_rate: %d\n\r",FileInfo.FileFormat.sample_rate);
00500 
00501     fread(&Sound.FileInfo.FileData,sizeof(Sound.FileInfo.FileData),1,wav_file);
00502     printf("wav_data.subchunk2_size: %d\n\r",Sound.FileInfo.FileData.subchunk2_size);
00503     Sound.FileInfo.slice_buf = ( char *)malloc(Sound.FileInfo.FileFormat.block_align);
00504     printf("Wav File Block Align (number of bytes per sample!!: %d\n\r", Sound.FileInfo.FileFormat.block_align);
00505     fread(Sound.FileInfo.slice_buf,Sound.FileInfo.FileFormat.block_align,1,wav_file);   //This isnt actually required, its just a test
00506     Sound.FileInfo.num_slices = Sound.FileInfo.FileData.subchunk2_size/Sound.FileInfo.FileFormat.block_align;
00507     //printf("Number of Slices: %d\n\r",FileInfo.num_slices);
00508     return Sound;
00509 }
00510 
00511 
00512 //Function to initialise Data for classFade objects.  Perhaps move this into a constructor for the class?  (class still to be added)
00513 /*
00514 classFade FadeDataInitialise(classFade FadeData)
00515 {
00516     FadeData.DecayFactor = 1.3;
00517     FadeData.FadeIteration = 1;
00518     //FadeData.Denom = 11025*FadeData.DecayFactor;
00519     FadeData.Denom = 11025*FadeData.DecayFactor;
00520     FadeData.Natural_Exp = 2.7183;
00521     FadeData.Length = 11025*FadeData.LengthSecs;
00522     //FadeData.Natural_Exp = 2.7;
00523     return FadeData;
00524 }
00525 */
00526 
00527 
00528 
00529 
00530 void Play_WaveFile(FILE * my_wav, WAV_FILE_STRUCT FileInfo)
00531 {
00532     while(slice<FileInfo.num_slices) {
00533         fread(FileInfo.slice_buf,FileInfo.FileFormat.block_align,1,my_wav);
00534         data_sptr=(short *)FileInfo.slice_buf;     // 16 bit samples
00535         for (channel=0; channel<FileInfo.FileFormat.num_channels; channel++) {
00536             if(flag1 == 1) {
00537                 Buffer1[place_hold1] = data_sptr[channel];
00538                 place_hold1 = place_hold1 + 1;
00539                 if(place_hold1 >= BufferLen) {
00540                     while(1) {
00541                         if(flag1 == 0) {
00542 
00543                             break;
00544                         }
00545 
00546                     }
00547                 }
00548 
00549             } else if(flag2 == 1) {
00550                 Buffer2[place_hold2] = data_sptr[channel];
00551                 place_hold2 = place_hold2 + 1;
00552                 if(place_hold2 >= BufferLen) {
00553 
00554                     while(1) {
00555                         if(flag2 == 0) {
00556 
00557                             break;
00558                         }
00559                     }
00560                 }
00561             }
00562 
00563         }
00564         slice = slice + 1;
00565     }
00566 }
00567 
00568 
00569 
00570 
00571 //***************************************************************************//
00572 
00573 //**************************************************************************//
00574 
00575 
00576 
00577 
00578 
00579 
00580 
00581 void Play_WaveFileLoop(classSoundFile Sound1, classSoundFile Sound2, FILE *wavfile1, FILE* wavfile2, classPositionIndicators Positions)
00582 {
00583     while(1) { //might have to change this to a while(1) loop?
00584 
00585 
00586 
00587 
00588 
00589 //Sound1=======================================================================================
00590         if( slice1 == (Positions.notch_start_pts[NotchingSet.Notch + 1]) ) {
00591             slice1 = Positions.notch_start_pts[NotchingSet.Notch];
00592             fseek(wavfile1,Positions.notch_start_pts[NotchingSet.Notch],SEEK_SET);
00593         }
00594    
00595             fread(Sound1.FileInfo.slice_buf,Sound1.FileInfo.FileFormat.block_align,1,wavfile1);
00596             /*OperationsTimer.stop();
00597             printf("It took %d useconds to perform fread operation.\n\r",OperationsTimer.read_us());
00598             Positions.notch_position_indicators[1] = Positions.notch_position_indicators[1] + 2;//i.e. 2 bytes, per sample, for 2-byte (16-bit) data
00599             */
00600             data_sptr1=(short *)Sound1.FileInfo.slice_buf;
00601             *Sound1.data_sptr = *data_sptr1;
00602             //Sound1.data_sptr=(short *)Sound1.FileInfo.slice_buf;     // 16 bit samples
00603         
00604   
00605 //=============================================================================================
00606 
00607 
00608 
00609 
00610 
00611         for (channel=0; channel<Sound1.FileInfo.FileFormat.num_channels; channel++) {
00612             switch (Sound1.FileInfo.FileFormat.sig_bps) {
00613                 case 16:
00614                     if(flag1 == 1) {
00615                         Buffer1[place_hold1] = Sound1.data_sptr[channel];
00616                         place_hold1 = place_hold1 + 1;
00617                         if(place_hold1 >= BufferLen) {
00618                             while(1) {
00619                                 if(flag1 == 0) {
00620                                     break;
00621                                 }//if(flag1 == 0)
00622 
00623 
00624                             }//while(1)
00625                         }//if(place_hold1 > = BufferLen)
00626 
00627                     } else if(flag2 == 1) {
00628                         Buffer2[place_hold2] = Sound1.data_sptr[channel];
00629                         place_hold2 = place_hold2 + 1;
00630                         if(place_hold2 >= BufferLen) {
00631                             while(1) {
00632 
00633                                 if(flag2 == 0) {
00634                                     break;
00635                                 }
00636                             }
00637                         }
00638 
00639                     }
00640             }
00641         }
00642         slice1 = slice1 + 2;//increment up by the number of bytes per Audio data sample!  Makes sense it is 2 bytes, as this is 16-bit data.
00643         slice2 = slice2 + 1;
00644         slice3 = slice3 + 1;
00645     }
00646 }
00647 
00648 
00649 
00650 
00651 
00652 
00653