diff options
author | Florian Jung <flo@windfisch.org> | 2012-05-28 14:15:52 +0000 |
---|---|---|
committer | Florian Jung <flo@windfisch.org> | 2012-05-28 14:15:52 +0000 |
commit | d2a88cfaad5ac385fc3c6212c09ad7fbc38e9454 (patch) | |
tree | 387da0b38255003e1a971629ea0de32273ac3d3c /muse2/muse/audio.cpp | |
parent | 716f5a5b56a3b7ff59004ef0a1af5f98cb2a691c (diff) |
merged with release_2_0
Diffstat (limited to 'muse2/muse/audio.cpp')
-rw-r--r-- | muse2/muse/audio.cpp | 48 |
1 files changed, 36 insertions, 12 deletions
diff --git a/muse2/muse/audio.cpp b/muse2/muse/audio.cpp index 80bffafe..cbcbd922 100644 --- a/muse2/muse/audio.cpp +++ b/muse2/muse/audio.cpp @@ -59,13 +59,9 @@ void initAudio() { MusEGlobal::audio = new Audio(); } - extern double curTime(); -//static const unsigned char mmcDeferredPlayMsg[] = { 0x7f, 0x7f, 0x06, 0x03 }; DELETETHIS 2 -//static const unsigned char mmcStopMsg[] = { 0x7f, 0x7f, 0x06, 0x01 }; - const char* seqMsgList[] = { "SEQM_ADD_TRACK", "SEQM_REMOVE_TRACK", //"SEQM_CHANGE_TRACK", DELETETHIS "SEQM_MOVE_TRACK", @@ -82,6 +78,7 @@ const char* seqMsgList[] = { "SEQM_SET_HW_CTRL_STATES", "SEQM_SET_TRACK_OUT_PORT", "SEQM_SET_TRACK_OUT_CHAN", + "SEQM_SET_TRACK_AUTO_TYPE", "SEQM_REMAP_PORT_DRUM_CTL_EVS", "SEQM_CHANGE_ALL_PORT_DRUM_CTL_EVS", "SEQM_SCAN_ALSA_MIDI_PORTS", @@ -216,9 +213,8 @@ bool Audio::start() } } + _running = true; // Set before we start to avoid error messages in process. MusEGlobal::audioDevice->start(MusEGlobal::realTimePriority); - - _running = true; // shall we really stop JACK transport and locate to // saved position? @@ -715,6 +711,10 @@ void Audio::processMsg(AudioMsg* msg) MusEGlobal::midiSeq->sendMsg(msg); break; + case SEQM_SET_TRACK_AUTO_TYPE: + msg->track->setAutomationType(AutomationType(msg->ival)); + break; + case SEQM_IDLE: idle = msg->a; MusEGlobal::midiSeq->sendMsg(msg); @@ -976,10 +976,7 @@ void Audio::recordStop() if(ao->recordFlag()) { MusEGlobal::song->bounceOutput = 0; - SndFile* sf = ao->recFile(); - if (sf) - delete sf; // close - ao->setRecFile(0); + ao->setRecFile(NULL); // if necessary, this automatically deletes _recFile ao->setRecordFlag1(false); msgSetRecord(ao, false); } @@ -990,17 +987,44 @@ void Audio::recordStop() } //--------------------------------------------------------- +// framesSinceCycleStart +// Estimated frames since the last process cycle began +//--------------------------------------------------------- + +unsigned Audio::framesSinceCycleStart() const +{ + return lrint((curTime() - syncTime) * MusEGlobal::sampleRate); +} + +//--------------------------------------------------------- +// curFramePos() +// Current play position frame. Estimated to single-frame resolution while in play mode. +//--------------------------------------------------------- + +unsigned Audio::curFramePos() const +{ + return _pos.frame() + (isPlaying() ? framesSinceCycleStart() : 0); +} + +//--------------------------------------------------------- // curFrame -// extrapolates current play frame on syncTime/syncFrame +// Extrapolates current play frame on syncTime/syncFrame +// Estimated to single-frame resolution. +// This is an always-increasing number. Good for timestamps, and +// handling them during process when referenced to syncFrame. //--------------------------------------------------------- unsigned int Audio::curFrame() const { - return lrint((curTime() - syncTime) * MusEGlobal::sampleRate) + syncFrame; + //return lrint((curTime() - syncTime) * MusEGlobal::sampleRate) + syncFrame; + return framesSinceCycleStart() + syncFrame; } //--------------------------------------------------------- // timestamp +// Estimated to single-frame resolution. +// This is an always-increasing number in play mode, but in stop mode +// it is circular (about the cur pos, width = segment size). //--------------------------------------------------------- int Audio::timestamp() const |