Skip to content

Commit

Permalink
cleanup for switching between inputs
Browse files Browse the repository at this point in the history
  • Loading branch information
drs1980 committed May 17, 2013
1 parent 60ccf66 commit b4cccb9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
5 changes: 3 additions & 2 deletions Visualizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
extern Packet *sharedBuffer;
extern bool finished;
const char simpleArgs[] = {'c', 't', 'm', 'h'};
const char compoundArgs[] = {'w', 's', 'r'};
const char compoundArgs[] = {'f', 'w', 's', 'r'};
ArgMapper mapper;

void printUsage(const char *name){
Expand Down Expand Up @@ -80,7 +80,8 @@ int main(int argc, char *argv[]){

processArgs(argc, argv);

if (!startAudio(stream, argv[1], mapper.getCompoundArg('w').c_str())){
if (!startAudio(stream, mapper.getCompoundArg('f').c_str(),
mapper.getCompoundArg('w').c_str())){
exit(1);
}

Expand Down
5 changes: 4 additions & 1 deletion audio_helper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,12 @@ bool printError(PaError error, string msg){
//open and start the audio stream - takes stream, callback function, and userdata
bool startAudio(PaStream *stream, const char* filename, const char* windowname){

InputSource inputSource = filename == NULL ? Mic : File;
InputSource inputSource = strcasecmp(filename, "") == 0 ? Mic : File;
int samplerate = SAMPLE_RATE; //default if no file specified

//open file if we're not using Mic
if (inputSource == File){
printf("Reading from file %s\n", filename);
if ((sf.file = sf_open(filename, SFM_READ, &sf.info) ) == NULL) {
printf("Error opening file '%s' (see manual for accepted formats)\n", filename);
return false;
Expand All @@ -120,6 +121,8 @@ bool startAudio(PaStream *stream, const char* filename, const char* windowname){
return false;
}
samplerate = sf.info.samplerate;
} else {
printf("Reading from default input\n");
}

//port audio init stuff
Expand Down

0 comments on commit b4cccb9

Please sign in to comment.