Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/ofxSoundObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ void ofxSoundObject::setBypassed(bool bypassed){
// ofxSoundInput
//--------------------------------------------------------------
ofxSoundInput::ofxSoundInput():ofxSoundObject(OFX_SOUND_OBJECT_SOURCE) {
setName("Sound Input");
}
//--------------------------------------------------------------
size_t ofxSoundInput::getNumChannels(){
Expand Down Expand Up @@ -246,6 +247,7 @@ ofSoundStream* ofxSoundInput::getInputStream(){
// ofxSoundOutput
//--------------------------------------------------------------
ofxSoundOutput::ofxSoundOutput():ofxSoundObject(OFX_SOUND_OBJECT_DESTINATION) {
setName("Sound Output");
}

//--------------------------------------------------------------
52 changes: 47 additions & 5 deletions src/ofxSoundRecorderObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,15 +82,57 @@ void ofxSoundRecorderObject::threadedFunction(){
}
}
#endif
//--------------------------------------------------------------
void ofxSoundRecorderObject::audioOut(ofSoundBuffer &output){
ofxSoundObject* obj = getSignalSourceObject();
bool is_sound_input = false;
if(obj->getType() == OFX_SOUND_OBJECT_SOURCE)
{
if(obj->getName() == "Sound Input")
{
if(ofxSoundUtils::checkBuffers(output, getBuffer(), false))
{
is_sound_input = true;
auto& buffer = getBuffer();
ofxSoundInput* input = (ofxSoundInput*)obj;
ofSoundStream* ss = input->getInputStream();
int buffer_size = ss->getBufferSize() * ss->getNumInputChannels();
buffer.resize(buffer_size);
buffer.setNumChannels(ss->getNumInputChannels());
buffer.setSampleRate(ss->getSampleRate());
}
}
}
if(!is_sound_input)
{
ofxSoundUtils::checkBuffers(output, getBuffer());
}
if(inputObject != NULL)
{
if(isBypassed())
{
inputObject->audioOut(output);
}
else
{
inputObject->audioOut(getBuffer());
}
}
if(!isBypassed())
{
process(getBuffer(), output);
}
}

//--------------------------------------------------------------
void ofxSoundRecorderObject::process(ofSoundBuffer &input, ofSoundBuffer &output){
input.copyTo(output);
input.copyTo(output, output.getNumFrames(), output.getNumChannels(), 0);
#ifdef OFX_SOUND_ENABLE_THREADED_RECORDER
if(recState != IDLE){
writeChannel.send(input);
}
if(recState != IDLE){
writeChannel.send(input);
}
#else
write(input);
write(input);
#endif
}
//--------------------------------------------------------------
Expand Down
1 change: 1 addition & 0 deletions src/ofxSoundRecorderObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class ofxSoundRecorderObject: public ofxSoundObject{
#ifdef OFX_SOUND_ENABLE_THREADED_RECORDER
virtual ~ofxSoundRecorderObject();
#endif
virtual void audioOut(ofSoundBuffer &output) override;
virtual void process(ofSoundBuffer &input, ofSoundBuffer &output) override;


Expand Down