comparison 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
comparison
equal deleted inserted replaced
67:0ede0715dbd6 68:44cc00df1168
67 voiceFini[i] <= False; 67 voiceFini[i] <= False;
68 endrule 68 endrule
69 69
70 rule processSample(!isAudioFini(voiceFini)); //implicit on all voiceFifos having data 70 rule processSample(!isAudioFini(voiceFini)); //implicit on all voiceFifos having data
71 FixedPoint#(32,32) sum = 0; //this should allow 16 voices at 16 bits without messing up 71 FixedPoint#(32,32) sum = 0; //this should allow 16 voices at 16 bits without messing up
72 Integer numValid = 0;
72 for (Integer i = 0; i < numVoices; i = i+1) 73 for (Integer i = 0; i < numVoices; i = i+1)
73 begin 74 begin
74 if (voicesIn[i].first() matches tagged Valid .data) 75 if (voicesIn[i].first() matches tagged Valid .data)
75 begin 76 begin
76 case (data) matches 77 case (data) matches
77 tagged Sample .sample : 78 tagged Sample .sample :
78 sum = sum + ((fromInt(sample) * fromInt(scalars[i])) >> 8); 79 begin //shifting right 8 to divide by 256
79 //shifting right 8 to divide by 256 80 sum = sum + ((fromInt(sample) * fromInt(scalars[i])) >> 8);
81 numValid = numValid + 1;
82 end
80 tagged EndOfFile : 83 tagged EndOfFile :
81 voiceFini[i] <= True; 84 voiceFini[i] <= True;
82 endcase 85 endcase
83 end 86 end
84 else voiceFini[i] <= True; 87 else voiceFini[i] <= True;
85 voicesIn[i].deq(); 88 voicesIn[i].deq();
86 end 89 end
87 90 if (numValid > 0) // If nothing is valid, don't send anything
88 masterFifo.enq(tagged Sample truncate(fxptGetInt(sum >> numVoices))); 91 masterFifo.enq(tagged Sample truncate(fxptGetInt(sum >> numVoices)));
89 endrule 92 endrule
90 93
91 // Internal connections 94 // Internal connections
92 95
93 // method Action loadMixerFifos(AudioStream voiceInput);
94 // voicesIn[voiceInput.voice].enq(voiceInput.data);
95 // endmethod
96
97 method Action toMixer(AudioStream streamIn); 96 method Action toMixer(AudioStream streamIn);
98 voicesIn[streamIn.voice].enq(streamIn.data); 97 voicesIn[streamIn.voice].enq(streamIn.data);
99 endmethod 98 endmethod
100 99
101 interface Get mainOut = fifoToGet(masterFifo); 100 interface Get mainOut = fifoToGet(masterFifo);