Skip to content

Instantly share code, notes, and snippets.

@prisonerjohn
Created May 26, 2015 19:21
Show Gist options
  • Save prisonerjohn/4b635baf3eb94830c162 to your computer and use it in GitHub Desktop.
Save prisonerjohn/4b635baf3eb94830c162 to your computer and use it in GitHub Desktop.
ofxAudioDecoder to libsndfile
sfInfo.frames = audioDecoder.getNumFrames();
sfInfo.samplerate = audioDecoder.getSampleRate();
sfInfo.channels = audioDecoder.getChannels();
sfInfo.format = SF_FORMAT_WAV;
sfInfo.sections = 1;
sfInfo.seekable = SF_TRUE;
SNDFILE * f = sf_open(ofToDataPath("testies.wav", true).c_str(), SFM_WRITE, &sfInfo);
// int err = sf_error(f);
// cout << "error " << err << endl;
const char* err = sf_strerror(f);
cout << "error is " << err << endl;
cout << "writing " << audioDecoder.getNumSamples() << " float samples" << endl;
int count = sf_write_float(f, audioDecoder.getRawSamples().data(), audioDecoder.getNumSamples());
cout << "count is " << count << endl;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment