Recorder.cpp

Go to the documentation of this file.
00001 /*******************************************************************************
00002  * Recorder.cpp (JackFX) 
00003  ******************************************************************************/
00004 
00005 #include "Recorder.h"
00006 
00007 Recorder::Recorder()
00008 {
00009     m_location = m_frames.begin();
00010 }
00011 
00012 Recorder::~Recorder()
00013 {
00014     Clear();
00015 }
00016 
00017 void Recorder::Clear()
00018 {
00019     Lock l(this);
00020     m_playing = false;
00021     while (m_location != m_frames.end()) {
00022         delete *m_location;
00023         m_frames.erase(m_location);
00024         m_location = m_frames.begin();
00025     }
00026 }
00027 
00028 void Recorder::Play()
00029 {
00030     m_location = m_frames.begin();
00031     m_playing = true;
00032 }
00033 
00034 void Recorder::Loop(bool looping)
00035 {
00036     m_looping = looping;
00037 }
00038 
00039 void Recorder::Stop()
00040 {
00041     m_playing = false;
00042     m_recording = false;
00043 }
00044 
00045 void Recorder::Record()
00046 {
00047     m_recording = true;
00048 }
00049 
00050 
00051 void Recorder::Process(jack_nframes_t count)
00052 {
00053     Lock l(this);
00054     ISoundElement::Process(count);
00055     
00056     if (m_recording) {
00057         SoundFrame* f = new SoundFrame();
00058         f->Set(GetPipe());
00059         m_frames.push_back(f);
00060     }
00061 
00062     if (m_playing && m_location != m_frames.end()) {
00063         GetPipe().Set(**m_location);
00064         ++m_location;
00065 
00066         if (m_location == m_frames.end()) {
00067             m_location = m_frames.begin();
00068             if (!m_looping) {
00069                 m_playing = false;
00070             }
00071         }
00072     }
00073 }
00074 

Get JackFX at SourceForge.net. Fast, secure and Free Open Source software downloads
Generated for JackFX by  doxygen