diff modules/bluespec/Pygar/core/Mixer.bsv @ 68:44cc00df1168 pygar svn.69

[svn r69] runs separate eofs (I think)
author punk
date Wed, 12 May 2010 00:06:05 -0400
parents 2991344775f8
children
line wrap: on
line diff
     1.1 --- a/modules/bluespec/Pygar/core/Mixer.bsv	Tue May 11 23:23:21 2010 -0400
     1.2 +++ b/modules/bluespec/Pygar/core/Mixer.bsv	Wed May 12 00:06:05 2010 -0400
     1.3 @@ -69,14 +69,17 @@
     1.4     
     1.5     rule processSample(!isAudioFini(voiceFini));  //implicit on all voiceFifos having data
     1.6        FixedPoint#(32,32) sum = 0;  //this should allow 16 voices at 16 bits without messing up
     1.7 +      Integer numValid = 0;
     1.8        for (Integer i = 0; i < numVoices; i = i+1)
     1.9  	 begin
    1.10  	    if (voicesIn[i].first() matches tagged Valid .data)
    1.11  	      begin
    1.12  		 case (data) matches
    1.13  		    tagged Sample .sample :
    1.14 -	               sum = sum + ((fromInt(sample) * fromInt(scalars[i])) >> 8); 
    1.15 -	            //shifting right 8 to divide by 256
    1.16 +		       begin //shifting right 8 to divide by 256
    1.17 +			  sum = sum + ((fromInt(sample) * fromInt(scalars[i])) >> 8); 
    1.18 +			  numValid = numValid + 1;
    1.19 +		       end
    1.20  		    tagged EndOfFile :
    1.21  		       voiceFini[i] <= True;
    1.22  		 endcase
    1.23 @@ -84,16 +87,12 @@
    1.24  	    else voiceFini[i] <= True;
    1.25  	    voicesIn[i].deq();
    1.26  	 end
    1.27 -      
    1.28 -       masterFifo.enq(tagged Sample truncate(fxptGetInt(sum >> numVoices)));
    1.29 +       if (numValid > 0)  // If nothing is valid, don't send anything
    1.30 +	  masterFifo.enq(tagged Sample truncate(fxptGetInt(sum >> numVoices)));
    1.31     endrule
    1.32   
    1.33    // Internal connections
    1.34  
    1.35 -//   method Action loadMixerFifos(AudioStream voiceInput);
    1.36 -//      voicesIn[voiceInput.voice].enq(voiceInput.data);
    1.37 -//   endmethod
    1.38 - 
    1.39     method Action toMixer(AudioStream streamIn);
    1.40  	 voicesIn[streamIn.voice].enq(streamIn.data);
    1.41     endmethod