annotate modules/bluespec/Pygar/common/AudioProcessor.bsv @ 36:99519a031813 pygar svn.37

[svn r37] moved the server into audioCorePipeline
author punk
date Tue, 04 May 2010 18:54:54 -0400
parents 74716e9a81cc
children
rev   line source
rlm@8 1 // The MIT License
rlm@8 2
rlm@8 3 // Copyright (c) 2009 Massachusetts Institute of Technology
rlm@8 4
rlm@8 5 // Permission is hereby granted, free of charge, to any person obtaining a copy
rlm@8 6 // of this software and associated documentation files (the "Software"), to deal
rlm@8 7 // in the Software without restriction, including without limitation the rights
rlm@8 8 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
rlm@8 9 // copies of the Software, and to permit persons to whom the Software is
rlm@8 10 // furnished to do so, subject to the following conditions:
rlm@8 11
rlm@8 12 // The above copyright notice and this permission notice shall be included in
rlm@8 13 // all copies or substantial portions of the Software.
rlm@8 14
rlm@8 15 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
rlm@8 16 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
rlm@8 17 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
rlm@8 18 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
rlm@8 19 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
rlm@8 20 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
rlm@8 21 // THE SOFTWARE.
rlm@8 22
rlm@8 23 import Connectable::*;
rlm@8 24 import GetPut::*;
rlm@8 25 import ClientServer::*;
rlm@8 26
rlm@8 27 //AWB includes
rlm@8 28 `include "asim/provides/low_level_platform_interface.bsh"
rlm@8 29 `include "asim/provides/soft_connections.bsh"
rlm@8 30 `include "asim/provides/common_services.bsh"
rlm@8 31
rlm@8 32 // Local includes
rlm@8 33 `include "asim/provides/audio_processor_types.bsh"
rlm@8 34 `include "asim/provides/audio_pipeline.bsh"
rlm@8 35
rlm@8 36 `include "asim/rrr/remote_client_stub_AUDIOPROCESSORRRR.bsh"
rlm@8 37 `include "asim/rrr/remote_server_stub_AUDIOPROCESSORRRR.bsh"
rlm@8 38
rlm@8 39
rlm@8 40 module [CONNECTED_MODULE] mkConnectedApplication ();
rlm@8 41
rlm@8 42 // Instantiate the rrr stubs
rlm@8 43 ClientStub_AUDIOPROCESSORRRR client_stub <- mkClientStub_AUDIOPROCESSORRRR();
rlm@8 44 ServerStub_AUDIOPROCESSORRRR server_stub <- mkServerStub_AUDIOPROCESSORRRR();
rlm@8 45
rlm@8 46 // Instantiate the audio pipeline
rlm@8 47 AudioPipeline pipeline <- mkAudioPipeline();
rlm@8 48
rlm@8 49 rule feedInput;
rlm@8 50 let command <- server_stub.acceptRequest_SendUnprocessedStream();
rlm@8 51 AudioProcessorControl ctrl = unpack(truncate(command.ctrl));
rlm@8 52
rlm@8 53 if(ctrl == EndOfFile)
rlm@8 54 begin
rlm@8 55 pipeline.sampleInput.put(tagged EndOfFile);
rlm@8 56 end
rlm@8 57 else
rlm@8 58 begin
rlm@8 59 pipeline.sampleInput.put(tagged Sample unpack(truncate(command.sample)));
rlm@8 60 end
rlm@8 61 endrule
rlm@8 62
rlm@8 63 rule feedOutput;
rlm@8 64 let pipelineData <- pipeline.sampleOutput.get();
rlm@8 65 AudioProcessorControl endOfFileTag = EndOfFile;
rlm@8 66 AudioProcessorControl sampleTag = Data;
rlm@8 67
rlm@8 68 case (pipelineData) matches
rlm@8 69 tagged EndOfFile: client_stub.makeRequest_SendProcessedStream(zeroExtend(pack(endOfFileTag)),?);
rlm@8 70 tagged Sample .sample:client_stub.makeRequest_SendProcessedStream(zeroExtend(pack(sampleTag)),
rlm@8 71 zeroExtend(pack(sample)));
rlm@8 72 endcase
rlm@8 73 endrule
rlm@8 74
rlm@8 75 endmodule
rlm@8 76
rlm@8 77