# HG changeset patch # User rlm # Date 1272423986 14400 # Node ID bb7db7d1b37c9076f3837e0f7e0426e138b5bff6 # Parent 9d1f38722f5b6c59e19f706ca6ed8cc10834d7a2 [svn r19] removed garbage diff -r 9d1f38722f5b -r bb7db7d1b37c #AudioProcessor.cpp# --- a/#AudioProcessor.cpp# Tue Apr 27 22:55:55 2010 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,104 +0,0 @@ -#include -#include -#include - -#include "asim/provides/connected_application.h" -//#include "asim/provides/SndfileWavUtil.h" - -#include "asim/rrr/client_stub_AUDIOPROCESSORRRR.h" - -using namespace std; - -pthread_mutex_t CONNECTED_APPLICATION_CLASS::lock; -pthread_cond_t CONNECTED_APPLICATION_CLASS::cond; -sem_t CONNECTED_APPLICATION_CLASS::throttle; - -// constructor -CONNECTED_APPLICATION_CLASS::CONNECTED_APPLICATION_CLASS(VIRTUAL_PLATFORM vp) : - clientStub(new AUDIOPROCESSORRRR_CLIENT_STUB_CLASS(this)) -{ -œôøº} -œôøºœôøºœôøº -// destructor -CONNECTED_APPLICATION_CLASS::~CONNECTED_APPLICATION_CLASS() -{ -} - -// init -void -CONNECTED_APPLICATION_CLASS::Init() -{ - - pthread_mutex_init(&lock, NULL); - pthread_cond_init(&cond, NULL); - sem_init(&throttle, 0, 64); - -} - -void -CONNECTED_APPLICATION_CLASS::UpdateSemaphore() -{ - sem_post(&throttle); -} - -void -CONNECTED_APPLICATION_CLASS::EndSimulation() -{ - printf("EndSimulation Called\n"); - fflush(stdout); - pthread_mutex_lock(&lock); - // Do something about the race occuring here - pthread_cond_signal(&cond); - pthread_mutex_unlock(&lock); - printf("EndSimulation done\n"); - fflush(stdout); -} - -// main -void -CONNECTED_APPLICATION_CLASS::Main() -{ - FILE *inputFile; - UINT16 sample; - - // Convert input wav to pcm - generate_pcm("input.wav","input.pcm"); - - //Send data to the machine here. - inputFile = fopen("input.pcm","r"); - assert(inputFile); - - - int count = 0; - - printf("main: about to enter loop %d\n", count); - - while(fread(&sample, 2, 1, inputFile)) { - if(count%1000 == 0) - printf("main: %d\n", count); - count++; - sem_wait(&throttle); - clientStub->SendUnprocessedStream(Data,(UINT32)sample); - } - - printf("main: out of loop\n"); - - // Need to put lock here to prevent potential race condition - pthread_mutex_lock(&lock); - clientStub->SendUnprocessedStream(EndOfFile,0); - - printf("main: wait for end of file\n"); - - pthread_cond_wait(&cond, &lock); - pthread_mutex_unlock(&lock); - - printf("main: lastt data out\n"); - - // Convert input wav to pcm - generate_wav("out_hw.pcm","input.wav","out_hw.wav"); - - printf("generate wav done\n"); - - fflush(stdout); - exit(0); -} diff -r 9d1f38722f5b -r bb7db7d1b37c #AudioProcessorRRR.rrr# --- a/#AudioProcessorRRR.rrr# Tue Apr 27 22:55:55 2010 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,14 +0,0 @@ -service AUDIOPROCESSORRRR -{ - server sw (cpp, method) <- hw (bsv, connection) - { - method SendProcessedStream (in UINT32[32] ctrl, in UINT32[32] sample); - }; - - server hw (bsv, connection) <- sw (cpp, method) - { - method SendUnprocessedStream (in UINT32[32] ctrl, in UINT32[32] sample); - }; - - - }; diff -r 9d1f38722f5b -r bb7db7d1b37c #AudioProcessorTypes.bsv# --- a/#AudioProcessorTypes.bsv# Tue Apr 27 22:55:55 2010 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,52 +0,0 @@ - -// The MIT License - -// Copyright (c) 2009 Massachusetts Institute of Technology - -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: - -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. - -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -// Author: Kermin Fleming kfleming@mit.edu - -import Connectable::*; -import GetPut::*; -import ClientServer::*; - -typedef Int#(16) Sample; - -typedef enum { - EndOfFile = 0, - Data = 1 -} AudioProcessorControl deriving (Bits,Eq); - - -typedef struct { - Sample left; - Sample right; -} StereoSample deriving (Bits,Eq); - -typedef union tagged{ - Sample Sample; - void EndOfFile; -} AudioProcessorUnit deriving (Bits,Eq); - -interface AudioPipeline; - interface Put#(AudioProcessorUnit) sampleInput; - interface Get#(AudioProcessorUnit) sampleOutput; -endinterface - diff -r 9d1f38722f5b -r bb7db7d1b37c AudioPipelineDefault.bsv --- a/AudioPipelineDefault.bsv Tue Apr 27 22:55:55 2010 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,38 +0,0 @@ -// The MIT License - -// Copyright (c) 2009 Massachusetts Institute of Technology - -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: - -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. - -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -// Author: Kermin Fleming kfleming@mit.edu - -import Connectable::*; -import GetPut::*; -import ClientServer::*; -import FIFO::*; - -`include "asim/provides/audio_processor_types.bsh" - -module mkAudioPipeline (AudioPipeline); - FIFO#(AudioProcessorUnit) fifo <- mkFIFO; - - interface sampleInput = fifoToPut(fifo); - interface sampleOutput = fifoToGet(fifo); - -endmodule diff -r 9d1f38722f5b -r bb7db7d1b37c AudioProcessor.bsv --- a/AudioProcessor.bsv Tue Apr 27 22:55:55 2010 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,77 +0,0 @@ -// The MIT License - -// Copyright (c) 2009 Massachusetts Institute of Technology - -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: - -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. - -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -import Connectable::*; -import GetPut::*; -import ClientServer::*; - -//AWB includes -`include "asim/provides/low_level_platform_interface.bsh" -`include "asim/provides/soft_connections.bsh" -`include "asim/provides/common_services.bsh" - -// Local includes -`include "asim/provides/audio_processor_types.bsh" -`include "asim/provides/audio_pipeline.bsh" - -`include "asim/rrr/remote_client_stub_AUDIOPROCESSORRRR.bsh" -`include "asim/rrr/remote_server_stub_AUDIOPROCESSORRRR.bsh" - - -module [CONNECTED_MODULE] mkConnectedApplication (); - - // Instantiate the rrr stubs - ClientStub_AUDIOPROCESSORRRR client_stub <- mkClientStub_AUDIOPROCESSORRRR(); - ServerStub_AUDIOPROCESSORRRR server_stub <- mkServerStub_AUDIOPROCESSORRRR(); - - // Instantiate the audio pipeline - AudioPipeline pipeline <- mkAudioPipeline(); - - rule feedInput; - let command <- server_stub.acceptRequest_SendUnprocessedStream(); - AudioProcessorControl ctrl = unpack(truncate(command.ctrl)); - - if(ctrl == EndOfFile) - begin - pipeline.sampleInput.put(tagged EndOfFile); - end - else - begin - pipeline.sampleInput.put(tagged Sample unpack(truncate(command.sample))); - end - endrule - - rule feedOutput; - let pipelineData <- pipeline.sampleOutput.get(); - AudioProcessorControl endOfFileTag = EndOfFile; - AudioProcessorControl sampleTag = Data; - - case (pipelineData) matches - tagged EndOfFile: client_stub.makeRequest_SendProcessedStream(zeroExtend(pack(endOfFileTag)),?); - tagged Sample .sample:client_stub.makeRequest_SendProcessedStream(zeroExtend(pack(sampleTag)), - zeroExtend(pack(sample))); - endcase - endrule - -endmodule - - diff -r 9d1f38722f5b -r bb7db7d1b37c AudioProcessor.cpp --- a/AudioProcessor.cpp Tue Apr 27 22:55:55 2010 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,104 +0,0 @@ -#include -#include -#include - -#include "asim/provides/connected_application.h" -//#include "asim/provides/SndfileWavUtil.h" - -#include "asim/rrr/client_stub_AUDIOPROCESSORRRR.h" - -using namespace std; - -pthread_mutex_t CONNECTED_APPLICATION_CLASS::lock; -pthread_cond_t CONNECTED_APPLICATION_CLASS::cond; -sem_t CONNECTED_APPLICATION_CLASS::throttle; - -// constructor -CONNECTED_APPLICATION_CLASS::CONNECTED_APPLICATION_CLASS(VIRTUAL_PLATFORM vp) : - clientStub(new AUDIOPROCESSORRRR_CLIENT_STUB_CLASS(this)) -{ -} - -// destructor -CONNECTED_APPLICATION_CLASS::~CONNECTED_APPLICATION_CLASS() -{ -} - -// init -void -CONNECTED_APPLICATION_CLASS::Init() -{ - - pthread_mutex_init(&lock, NULL); - pthread_cond_init(&cond, NULL); - sem_init(&throttle, 0, 64); - -} - -void -CONNECTED_APPLICATION_CLASS::UpdateSemaphore() -{ - sem_post(&throttle); -} - -void -CONNECTED_APPLICATION_CLASS::EndSimulation() -{ - printf("EndSimulation Called\n"); - fflush(stdout); - pthread_mutex_lock(&lock); - // Do something about the race occuring here - pthread_cond_signal(&cond); - pthread_mutex_unlock(&lock); - printf("EndSimulation done\n"); - fflush(stdout); -} - -// main -void -CONNECTED_APPLICATION_CLASS::Main() -{ - FILE *inputFile; - UINT16 sample; - - // Convert input wav to pcm - generate_pcm("input.wav","input.pcm"); - - //Send data to the machine here. - inputFile = fopen("input.pcm","r"); - assert(inputFile); - - - int count = 0; - - printf("main: about to enter loop %d\n", count); - - while(fread(&sample, 2, 1, inputFile)) { - if(count%1000 == 0) - printf("main: %d\n", count); - count++; - sem_wait(&throttle); - clientStub->SendUnprocessedStream(Data,(UINT32)sample); - } - - printf("main: out of loop\n"); - - // Need to put lock here to prevent potential race condition - pthread_mutex_lock(&lock); - clientStub->SendUnprocessedStream(EndOfFile,0); - - printf("main: wait for end of file\n"); - - pthread_cond_wait(&cond, &lock); - pthread_mutex_unlock(&lock); - - printf("main: lastt data out\n"); - - // Convert input wav to pcm - generate_wav("out_hw.pcm","input.wav","out_hw.wav"); - - printf("generate wav done\n"); - - fflush(stdout); - exit(0); -} diff -r 9d1f38722f5b -r bb7db7d1b37c AudioProcessor.h --- a/AudioProcessor.h Tue Apr 27 22:55:55 2010 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,56 +0,0 @@ -// -// INTEL CONFIDENTIAL -// Copyright (c) 2008 Intel Corp. Recipient is granted a non-sublicensable -// copyright license under Intel copyrights to copy and distribute this code -// internally only. This code is provided "AS IS" with no support and with no -// warranties of any kind, including warranties of MERCHANTABILITY, -// FITNESS FOR ANY PARTICULAR PURPOSE or INTELLECTUAL PROPERTY INFRINGEMENT. -// By making any use of this code, Recipient agrees that no other licenses -// to any Intel patents, trade secrets, copyrights or other intellectual -// property rights are granted herein, and no other licenses shall arise by -// estoppel, implication or by operation of law. Recipient accepts all risks -// of use. -// - -// possibly use include paths to hide existing modules? - -#ifndef __AUDIO_PROCESSOR_CONNECTED_APPLICATION__ -#define __AUDIO_PROCESSOR_CONNECTED_APPLICATION__ - -#include -#include -#include - -#include "asim/provides/virtual_platform.h" - -#include "asim/rrr/client_stub_AUDIOPROCESSORRRR.h" - -typedef enum { - EndOfFile = 0, - Data = 1 -} AudioProcessorControl; - - -typedef class CONNECTED_APPLICATION_CLASS* CONNECTED_APPLICATION; -class CONNECTED_APPLICATION_CLASS : public PLATFORMS_MODULE_CLASS -{ - private: - AUDIOPROCESSORRRR_CLIENT_STUB clientStub; - static sem_t throttle; - static pthread_mutex_t lock; - static pthread_cond_t cond; - - public: - CONNECTED_APPLICATION_CLASS(VIRTUAL_PLATFORM vp); - ~CONNECTED_APPLICATION_CLASS(); - static void EndSimulation(); - static void UpdateSemaphore(); - - // init - void Init(); - - // main - void Main(); -}; - -#endif diff -r 9d1f38722f5b -r bb7db7d1b37c AudioProcessorRRR.cpp --- a/AudioProcessorRRR.cpp Tue Apr 27 22:55:55 2010 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,93 +0,0 @@ -#include -#include -#include -#include -#include -#include - -#include "asim/rrr/service_ids.h" - -#include "asim/provides/connected_application.h" - - - -using namespace std; - -// ===== service instantiation ===== -AUDIOPROCESSORRRR_SERVER_CLASS AUDIOPROCESSORRRR_SERVER_CLASS::instance; - -// constructor -AUDIOPROCESSORRRR_SERVER_CLASS::AUDIOPROCESSORRRR_SERVER_CLASS() : - serverStub(new AUDIOPROCESSORRRR_SERVER_STUB_CLASS(this)) -{ - // instantiate stub - printf("AUDIOPROCESSORRR init called\n"); - outputFile = NULL; -} - -// destructor -AUDIOPROCESSORRRR_SERVER_CLASS::~AUDIOPROCESSORRRR_SERVER_CLASS() -{ - Cleanup(); -} - -// init -void -AUDIOPROCESSORRRR_SERVER_CLASS::Init(PLATFORMS_MODULE p) -{ - parent = p; -} - -// uninit -void -AUDIOPROCESSORRRR_SERVER_CLASS::Uninit() -{ - Cleanup(); -} - -// cleanup -void -AUDIOPROCESSORRRR_SERVER_CLASS::Cleanup() -{ - delete serverStub; -} - - -// -// RRR service methods -// - -void -AUDIOPROCESSORRRR_SERVER_CLASS::SendProcessedStream(UINT16 control, UINT16 data) -{ - - AudioProcessorControl audioProcessorControl = (AudioProcessorControl) control; - switch(control) { - case EndOfFile: - if(outputFile != NULL) { - fflush(outputFile); - fclose(outputFile); - outputFile = NULL; - } else { - outputFile = fopen("out_hw.pcm","w"); - assert(outputFile); - fflush(outputFile); - fclose(outputFile); - } - - CONNECTED_APPLICATION_CLASS::EndSimulation(); - break; - - case Data: - if(outputFile == NULL) { - outputFile = fopen("out_hw.pcm","w"); - assert(outputFile); - } - - CONNECTED_APPLICATION_CLASS::UpdateSemaphore(); - fwrite(&data, 2,1 , outputFile); - break; - } - -} - diff -r 9d1f38722f5b -r bb7db7d1b37c AudioProcessorRRR.h --- a/AudioProcessorRRR.h Tue Apr 27 22:55:55 2010 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,50 +0,0 @@ - -#ifndef _AUDIOPROCESSORRRR_ -#define _AUDIOPROCESSORRRR_ - -#include -#include - -#include "asim/provides/low_level_platform_interface.h" - -#include "asim/provides/rrr.h" - - - -typedef class AUDIOPROCESSORRRR_SERVER_CLASS* AUDIOPROCESSORRRR_SERVER; -class AUDIOPROCESSORRRR_SERVER_CLASS: public RRR_SERVER_CLASS, public PLATFORMS_MODULE_CLASS -{ - private: - // self-instantiation - static AUDIOPROCESSORRRR_SERVER_CLASS instance; - FILE *outputFile; - - // server stub - RRR_SERVER_STUB serverStub; - - int count; - - public: - AUDIOPROCESSORRRR_SERVER_CLASS(); - ~AUDIOPROCESSORRRR_SERVER_CLASS(); - - // static methods - static AUDIOPROCESSORRRR_SERVER GetInstance() { return &instance; } - - // required RRR methods - void Init(PLATFORMS_MODULE); - void Uninit(); - void Cleanup(); - - // - // RRR service methods - // - void SendProcessedStream(UINT16 control, UINT16 data0); -}; - - - -// include server stub -#include "asim/rrr/server_stub_AUDIOPROCESSORRRR.h" - -#endif diff -r 9d1f38722f5b -r bb7db7d1b37c AudioProcessorRRR.rrr --- a/AudioProcessorRRR.rrr Tue Apr 27 22:55:55 2010 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,14 +0,0 @@ -service AUDIOPROCESSORRRR -{ - server sw (cpp, method) <- hw (bsv, connection) - { - method SendProcessedStream (in UINT32[32] ctrl, in UINT32[32] sample); - }; - - server hw (bsv, connection) <- sw (cpp, method) - { - method SendUnprocessedStream (in UINT32[32] ctrl, in UINT32[32] sample); - }; - - - }; diff -r 9d1f38722f5b -r bb7db7d1b37c AudioProcessorTypes.bsv --- a/AudioProcessorTypes.bsv Tue Apr 27 22:55:55 2010 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,52 +0,0 @@ - -// The MIT License - -// Copyright (c) 2009 Massachusetts Institute of Technology - -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: - -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. - -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -// Author: Kermin Fleming kfleming@mit.edu - -import Connectable::*; -import GetPut::*; -import ClientServer::*; - -typedef Int#(16) Sample; - -typedef enum { - EndOfFile = 0, - Data = 1 -} AudioProcessorControl deriving (Bits,Eq); - - -typedef struct { - Sample left; - Sample right; -} StereoSample deriving (Bits,Eq); - -typedef union tagged{ - Sample Sample; - void EndOfFile; -} AudioProcessorUnit deriving (Bits,Eq); - -interface AudioPipeline; - interface Put#(AudioProcessorUnit) sampleInput; - interface Get#(AudioProcessorUnit) sampleOutput; -endinterface - diff -r 9d1f38722f5b -r bb7db7d1b37c DFT.cpp --- a/DFT.cpp Tue Apr 27 22:55:55 2010 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,46 +0,0 @@ -#include -#include -#include - - -int DFT(int dir,int m,double *x1,double *y1) -{ - long i,k; - double arg; - double cosarg,sinarg; - double *x2=NULL,*y2=NULL; - - x2 = (double *)(malloc(m*sizeof(double))); - y2 = (double *)(malloc(m*sizeof(double))); - if (x2 == NULL || y2 == NULL) - return 0; - - for (i=0;i -#include -#include -#include -#include -#include "SndfileWavUtil.h" - -void -generate_wav(const char * pcmfilename, const char * samplewavfilename, const char * outputwavfilename) -{ - char outfilename[2048]; - SNDFILE * outfile ; - SNDFILE * wavfile ; - SNDFILE * pcmfile ; - SF_INFO wavinfo ; - SF_INFO pcminfo ; - int buff; - SF_INSTRUMENT inst ; - - memset (&wavinfo, 0, sizeof (wavinfo)) ; - - - wavfile = sf_open(samplewavfilename, SFM_READ, &wavinfo); - - if (wavfile == NULL){ - printf ("\nERROR : Not able to open wav file named '%s' : %s/\n", samplewavfilename, sf_strerror (NULL)) ; - exit (1) ; - } ; - - printf("WAV format: %x\n", wavinfo.format); - - if (!((wavinfo.format & SF_FORMAT_PCM_16) && (wavinfo.channels == 1) && - (wavinfo.format & SF_FORMAT_WAV))){ - printf("\nERROR : .wav file must be SF_FORMAT_PCM_16 in mono\n"); - } - - pcminfo.format = SF_FORMAT_RAW | SF_FORMAT_PCM_16; - pcminfo.samplerate = wavinfo.samplerate; - pcminfo.channels = wavinfo.channels; - - pcmfile = sf_open(pcmfilename, SFM_READ, &pcminfo); - - if (pcmfile == NULL){ - printf ("\nERROR : Not able to open pcm file named '%s' : %s/\n", pcmfilename, sf_strerror (NULL)) ; - exit (1) ; - } ; - - - - outfile = sf_open(outputwavfilename, SFM_WRITE, &wavinfo); - - memset (&inst, 0, sizeof (inst)) ; - - for(int i = SF_STR_FIRST; i <= SF_STR_LAST; i = i + 1) { - const char * str = sf_get_string(wavfile,i); - if(str != NULL) { - sf_set_string(outfile,i,str); - } - } - - if (outfile == NULL){ - printf ("\nERROR : Not able to create wav file named '%s' : %s/\n", outfilename, sf_strerror (NULL)) ; - exit (1) ; - } ; - - while(sf_read_int(pcmfile, &buff, 1) == 1){ - if(sf_write_int(outfile, &buff, 1) != 1){ - printf("\nERROR : unable to write to '%s' : %s/\n", outfilename, sf_strerror(NULL)); - } - } - - sf_close (wavfile) ; - sf_close (outfile) ; - sf_close (pcmfile) ; - -} - - -void -generate_pcm (const char * wavfilename, const char * pcmfilename) -{ - SNDFILE * wavfile ; - SNDFILE * pcmfile ; - SF_INFO wavinfo ; - SF_INFO pcminfo ; - int buff; - - memset (&wavinfo, 0, sizeof (wavinfo)) ; - memset (&pcminfo, 0, sizeof (pcminfo)) ; - - wavfile = sf_open (wavfilename, SFM_READ, &wavinfo) ; - - if (wavfile == NULL){ - printf ("\nERROR : Not able to open wav file named '%s' : %s/\n", wavfilename, sf_strerror (NULL)) ; - exit (1) ; - } ; - - pcminfo.format = SF_FORMAT_RAW | SF_FORMAT_PCM_16; - pcminfo.samplerate = wavinfo.samplerate; - pcminfo.channels = wavinfo.channels; - - if ((!wavinfo.format & SF_FORMAT_PCM_16) || (!wavinfo.channels == 1)){ - printf("\nERROR : .wav file must be SF_FORMAT_PCM_16 and mono\n"); - } - - pcmfile = sf_open (pcmfilename, SFM_WRITE, &pcminfo) ; - - if (pcmfile == NULL){ - printf ("\nERROR : Not able to create pcm file named '%s' : %s/\n", pcmfilename, sf_strerror (NULL)) ; - exit (1) ; - } ; - - while(sf_read_int(wavfile, &buff, 1) == 1){ - if(sf_write_int(pcmfile, &buff, 1) != 1){ - printf("\nERROR : unable to write to '%s' : %s/\n", pcmfilename, sf_strerror(NULL)); - } - } - - sf_close (wavfile) ; - sf_close (pcmfile) ; -} - - - - diff -r 9d1f38722f5b -r bb7db7d1b37c SndfileWavUtil.h --- a/SndfileWavUtil.h Tue Apr 27 22:55:55 2010 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,9 +0,0 @@ -#ifndef _SNDFILE_WAV_UTIL_ -#define _SNDFILE_WAV_UTIL_ - -int guess_direction (const char * filename1, const char * filename2) ; -int guess_major_format (const char * filename) ; -void generate_pcm(const char * wavfilename, const char * pcmfilename); -void generate_wav(const char * pcmfilename, const char * samplewavfilename, const char * outputwavfilename); - -#endif diff -r 9d1f38722f5b -r bb7db7d1b37c audio_pipeline_default.awb --- a/audio_pipeline_default.awb Tue Apr 27 22:55:55 2010 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,10 +0,0 @@ -%name Default Audio Pipeline -%desc A basic copy-though audio pipeline - -%provides audio_pipeline - -%attributes 6_375 - -%public AudioPipelineDefault.bsv - - diff -r 9d1f38722f5b -r bb7db7d1b37c audio_processor_hardware_system.awb --- a/audio_processor_hardware_system.awb Tue Apr 27 22:55:55 2010 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,19 +0,0 @@ -%name Audio Processor Application -%desc Top level audio processor. This module wraps an Audio Pipeline, providing communications between host and audio processor - -%provides connected_application - -%requires audio_processor_types -%requires audio_pipeline - -%attributes 6_375 - -%sources -t H -v PUBLIC AudioProcessor.h -%sources -t H -v PUBLIC AudioProcessorRRR.h -%sources -t H -v PUBLIC SndfileWavUtil.h -%sources -t BSV -v PUBLIC AudioProcessor.bsv -%sources -t CPP -v PRIVATE AudioProcessor.cpp -%sources -t CPP -v PRIVATE AudioProcessorRRR.cpp -%sources -t CPP -v PRIVATE SndfileWavUtil.cpp -%sources -t RRR -v PUBLIC AudioProcessorRRR.rrr -%library /usr/lib/libsndfile.so diff -r 9d1f38722f5b -r bb7db7d1b37c audio_processor_software_system.awb --- a/audio_processor_software_system.awb Tue Apr 27 22:55:55 2010 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,16 +0,0 @@ -******************************************************************** -* Awb module specification -******************************************************************** - -%AWB_START - -%name Audio Processor Software -%desc Audio Processor Software -%provides software_system - -%attributes 6_375 - -%public AudioProcessor.cpp -%public AudioProcessor.h - -%AWB_END diff -r 9d1f38722f5b -r bb7db7d1b37c audio_processor_types.awb --- a/audio_processor_types.awb Tue Apr 27 22:55:55 2010 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,9 +0,0 @@ -%name Audio Processor Types -%desc Audio Processing Pipeline Types - -%provides audio_processor_types - -%attributes 6_375 - -%public AudioProcessorTypes.bsv -