diff modules/bluespec/Pygar/core/AudioCoreSystem.cpp @ 34:1a21b4cd85ee pygar svn.35

[svn r35] fixed the perl scripts and c files to handle multiple voices
author rlm
date Tue, 04 May 2010 12:08:19 -0400
parents 0c775e733b81
children 99519a031813
line wrap: on
line diff
     1.1 --- a/modules/bluespec/Pygar/core/AudioCoreSystem.cpp	Tue May 04 10:13:53 2010 -0400
     1.2 +++ b/modules/bluespec/Pygar/core/AudioCoreSystem.cpp	Tue May 04 12:08:19 2010 -0400
     1.3 @@ -62,8 +62,15 @@
     1.4  void
     1.5  CONNECTED_APPLICATION_CLASS::Main()
     1.6  {
     1.7 +  //rlm: two files
     1.8    FILE *inputFile;
     1.9 +  FILE *inputFile1;
    1.10    UINT16 sample;
    1.11 +  UINT16 sample1;
    1.12 +
    1.13 +  //rlm: not sure if normal ints are ok here; using UINT16 because I know it works
    1.14 +  UINT16 channel0 = 0;
    1.15 +  UINT16 channel1 = 1;
    1.16  
    1.17    //init processor 
    1.18    int sleepCount = 0;
    1.19 @@ -71,20 +78,35 @@
    1.20  
    1.21    bool coreFin = false; 
    1.22  
    1.23 +  
    1.24 +
    1.25    fflush(stdout); 
    1.26  
    1.27    // Convert input wav to pcm
    1.28 + 
    1.29 +
    1.30 +  //rlm: for now we are going to going to just have 2 files with "common names"
    1.31 +
    1.32    generate_pcm("input.wav","input.pcm");
    1.33 +  generate_pcm("input1.wav", "input1.pcm");
    1.34 +
    1.35 +
    1.36  
    1.37    //Send data to the machine here.
    1.38 +  //rlm: two files
    1.39    inputFile = fopen("input.pcm","r");
    1.40 +  inputFile = fopen("input1.pcm", "r");
    1.41 +  
    1.42 +  assert(inputFile1);
    1.43    assert(inputFile);
    1.44  
    1.45    int count = 0;
    1.46  
    1.47    printf("main:PROCESSOR about to enter loop %d\n", count);  
    1.48  
    1.49 -  while(fread(&sample, 2, 1, inputFile)) {
    1.50 +  //rlm: here we read both files. later refactor into a function.
    1.51 +  // also, this will terminate when the FIRST file reaches its end.
    1.52 +  while( (fread(&sample, 2, 1, inputFile)) && (fread(&sample1, 2 , 1, inputFile1))) {
    1.53      if (!coreFin && (result = clientStub->ReadCPUToHost(0)) != 1) 
    1.54      {
    1.55        sleepCount++;
    1.56 @@ -107,8 +129,10 @@
    1.57        printf("main: %d\n", count);
    1.58      count++;
    1.59      sem_wait(&throttle);
    1.60 -//    printf("rlm:sending data to processor (%d)\n", count);
    1.61 -    clientStub->SendUnprocessedStream(Data,(UINT32)sample);
    1.62 +
    1.63 +    //rlm: two files.
    1.64 +    clientStub->SendUnprocessedStream(channel0 , Data,(UINT32)sample);
    1.65 +    clientStub->SendUnprocessedStream(channel1 , Data,(UINT32)sample1);
    1.66  
    1.67    } 
    1.68  
    1.69 @@ -116,7 +140,11 @@
    1.70  
    1.71    // Need to put lock here to prevent potential race condition
    1.72    pthread_mutex_lock(&lock);
    1.73 -  clientStub->SendUnprocessedStream(EndOfFile,0);
    1.74 +
    1.75 +  //rlm: have to send end-files to both voices.  
    1.76 +  // all of these operations wil eventually be moved into functions.
    1.77 +  clientStub->SendUnprocessedStream(channel0, EndOfFile,0);
    1.78 +  clientStub->SendUnprocessedStream(channel1, EndOfFile,0);
    1.79  
    1.80    printf("main: wait for end of file\n");
    1.81  
    1.82 @@ -126,6 +154,7 @@
    1.83    printf("main: last data out\n");
    1.84  
    1.85    // Convert input wav to pcm
    1.86 +  // this part is ok because there is always only one input file.
    1.87    generate_wav("out_hw.pcm","input.wav","out_hw.wav");
    1.88  
    1.89    printf("generate wav done\n");