Mercurial > pygar
diff common/Mixer.bsv @ 2:996f1d6cd010 pygar svn.3
[svn r3] added pseudo code for Mixer, and defined Samples and VoiceID in PathTypes.
author | rlm |
---|---|
date | Wed, 14 Apr 2010 15:02:32 -0400 |
parents | |
children | cdad17407328 |
line wrap: on
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/common/Mixer.bsv Wed Apr 14 15:02:32 2010 -0400 1.3 @@ -0,0 +1,42 @@ 1.4 +import FIFOF::*; 1.5 +import FIFO::*; 1.6 + 1.7 + 1.8 +interface Mixer; 1.9 + method Action feed(Sample samp, VoiceId id); // feed in a sample to a specific FIFOF 1.10 + method Action stream(); // Outputs muxed data. 1.11 +endinterface 1.12 + 1.13 + 1.14 +method vectorFull?(Vector#(FIFOF#(Sample)) vect) 1.15 + 1.16 + (reduce .notEmpty vect) 1.17 + 1.18 +endmethod 1.19 + 1.20 + 1.21 + 1.22 +module mkMixer(Mixer); 1.23 + 1.24 + FIFO output = mkFIFO(); 1.25 + 1.26 + 1.27 + // make vector of fifos, length = MAX_VOICES 1.28 + fifo_vect Vector#(FIFOF#(Sample)) = mkVector(`MAX_VOICES); 1.29 + 1.30 + 1.31 + for $i(1 .. `MAX_VOICES) 1.32 + begin 1.33 + fifo_vect[$i] = mkFIFOF(); 1.34 + end 1.35 + 1.36 + rule(vectorFull?(fifo_vect)) 1.37 + 1.38 + Sample out = (/ (reduce + fofo_vector) `MAX_VOICES) 1.39 + output.enq(out); 1.40 + 1.41 + endrule 1.42 + 1.43 + 1.44 +endmodule 1.45 +