diff modules/bluespec/Pygar/core/Mixer.bsv @ 53:2991344775f8 pygar svn.54

[svn r54] mixer integrated
author punk
date Sun, 09 May 2010 10:58:40 -0400
parents 9b0dfce52c29
children 44cc00df1168
line wrap: on
line diff
     1.1 --- a/modules/bluespec/Pygar/core/Mixer.bsv	Thu May 06 08:57:53 2010 -0400
     1.2 +++ b/modules/bluespec/Pygar/core/Mixer.bsv	Sun May 09 10:58:40 2010 -0400
     1.3 @@ -27,8 +27,6 @@
     1.4  import FIFO::*;
     1.5  import FixedPoint::*;
     1.6  
     1.7 -`define MAX_VOICES 2
     1.8 -
     1.9  //AWB includes
    1.10  `include "asim/provides/low_level_platform_interface.bsh"
    1.11  `include "asim/provides/soft_connections.bsh"
    1.12 @@ -38,44 +36,40 @@
    1.13  `include "asim/provides/audio_pipe_types.bsh"
    1.14  `include "asim/provides/path_types.bsh"
    1.15  
    1.16 -interface PutMixerIn;
    1.17 -   method Action sendVoiceIn(AudioStream voiceInput);
    1.18 -endinterface 
    1.19 -
    1.20  interface Mixer;
    1.21 -   interface PutMixerIn toMixer;
    1.22 -   interface Get#(AudioProcessorUnit) mixerOut;
    1.23 +   method Action toMixer(AudioStream streamIn);
    1.24 +   interface Get#(AudioProcessorUnit) mainOut;
    1.25  endinterface
    1.26  
    1.27 -function Bool isAudioFini(Vector#(`MAX_VOICES, Reg#(Bool)) voiceStat);
    1.28 -   Bool result = True;
    1.29 -   for (Integer i = 0; i < `MAX_VOICES; i = i+1)
    1.30 -      begin
    1.31 -         result = voiceStat[i] && result;
    1.32 -      end
    1.33 -   return result; 
    1.34 -endfunction
    1.35 +module [CONNECTED_MODULE]  mkMixer#(Integer numVoices, Vector#(numVoices, Volume) scalars) (Mixer);
    1.36  
    1.37 -module [CONNECTED_MODULE]  mkMixer#(Vector#(`MAX_VOICES, Volume) scalars) (Mixer);
    1.38 +   function Bool isAudioFini(Vector#(numVoices, Reg#(Bool)) voiceStat);
    1.39 +     Bool result = True;
    1.40 +      for (Integer i = 0; i < numVoices; i = i+1)
    1.41 +        begin
    1.42 +          result = voiceStat[i] && result;
    1.43 +        end
    1.44 +     return result; 
    1.45 +   endfunction
    1.46  
    1.47  	 
    1.48    // Instantiate the modules
    1.49 -   Vector#(`MAX_VOICES, FIFO#(AudioPipeUnit)) voicesIn <- replicateM(mkFIFO());
    1.50 +   Vector#(numVoices, FIFO#(AudioPipeUnit)) voicesIn <- replicateM(mkFIFO());
    1.51  // <- newVector();
    1.52 -   Vector#(`MAX_VOICES, Reg#(Bool)) voiceFini <- replicateM(mkReg(False));
    1.53 +   Vector#(numVoices, Reg#(Bool)) voiceFini <- replicateM(mkReg(False));
    1.54  
    1.55     FIFO#(AudioProcessorUnit) masterFifo <- mkFIFO();
    1.56  
    1.57     rule sendEnd(isAudioFini(voiceFini));
    1.58        masterFifo.enq(tagged EndOfFile);
    1.59        //prep for reset
    1.60 -      for (Integer i = 0; i < `MAX_VOICES; i = i+1)
    1.61 +      for (Integer i = 0; i < numVoices; i = i+1)
    1.62  	 voiceFini[i] <= False;
    1.63     endrule
    1.64     
    1.65     rule processSample(!isAudioFini(voiceFini));  //implicit on all voiceFifos having data
    1.66        FixedPoint#(32,32) sum = 0;  //this should allow 16 voices at 16 bits without messing up
    1.67 -      for (Integer i = 0; i < `MAX_VOICES; i = i+1)
    1.68 +      for (Integer i = 0; i < numVoices; i = i+1)
    1.69  	 begin
    1.70  	    if (voicesIn[i].first() matches tagged Valid .data)
    1.71  	      begin
    1.72 @@ -91,17 +85,19 @@
    1.73  	    voicesIn[i].deq();
    1.74  	 end
    1.75        
    1.76 -       masterFifo.enq(tagged Sample truncate(fxptGetInt(sum >> `MAX_VOICES)));
    1.77 +       masterFifo.enq(tagged Sample truncate(fxptGetInt(sum >> numVoices)));
    1.78     endrule
    1.79   
    1.80    // Internal connections
    1.81  
    1.82 -   interface PutMixerIn toMixer;
    1.83 -      method Action sendVoiceIn(AudioStream voiceInput);
    1.84 -	 voicesIn[voiceInput.voice].enq(voiceInput.data);
    1.85 -      endmethod
    1.86 -   endinterface
    1.87 -      
    1.88 -   interface Get mixerOut = fifoToGet(masterFifo);
    1.89 +//   method Action loadMixerFifos(AudioStream voiceInput);
    1.90 +//      voicesIn[voiceInput.voice].enq(voiceInput.data);
    1.91 +//   endmethod
    1.92 + 
    1.93 +   method Action toMixer(AudioStream streamIn);
    1.94 +	 voicesIn[streamIn.voice].enq(streamIn.data);
    1.95 +   endmethod
    1.96 +   
    1.97 +   interface Get mainOut = fifoToGet(masterFifo);
    1.98  
    1.99  endmodule