Question

If I want to split a song I wrote into several separate .wav files, such as "drums.wav" "bass.wav" "guitar.wav" etc... is there anyway to have openFrameworks play all three files EXACTLY in sync so that the impression of a whole song is still there? Thanks!

Était-ce utile?

La solution

If I understand the question and all you want to do is play the files at the same time then you just have to create an ofSoundPlayer for each sample and set them to play at the same time.

In ofApp.h:

ofSoundPlayer drums, guitar, bass; // create sample players

In ofApp.cpp:

void ofApp::setup(){

drums.loadSound("drums.wav"); // do the same for bass and guitar

drums.play(); // play sample from start, same for bass and guitar


}

void ofApp::update(){

ofSoundUpdate();

}

This is assuming that all the samples start in sync. If you want to start a sample from a different position you can use:

drums.setPosition(float percent)

This is all well documented at http://openframeworks.cc/documentation/sound/ofSoundPlayer.html and is in the OpenFrameworks soundPlayer example (examples/sound/soundPlayerExample).

If you like things a little more complicated, I recommend Maximilian. It offers a lot of control, has a sample player and has an OpenFrameworks implementation but has less in the way of documentation. https://github.com/micknoise/Maximilian

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top