From 25537f78a1a35fc246b2da9e82f6cd61229c5223 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Mon, 5 Aug 2013 12:18:59 -0700 Subject: [PATCH] reset the song mix menu item after clip is done --- interface/src/Application.cpp | 12 ++++++++++-- interface/src/Application.h | 4 ++-- interface/src/Audio.cpp | 6 ++++-- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index a3bd6c4718..d638ae2b0a 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -2128,13 +2128,21 @@ void Application::toggleMixedSong() { QByteArray filenameArray = filename.toLocal8Bit(); _audio.importSongToMixWithMicrophone(filenameArray.data()); - _rawAudioMicrophoneMix->setText("Stop Mixing Song"); + resetSongMixMenuItem(); } else { _audio.stopMixingSongWithMicrophone(); - _rawAudioMicrophoneMix->setText("Mix RAW Song"); + resetSongMixMenuItem(); } } +void Application::resetSongMixMenuItem() { + if (_audio.getSongFileBytes() == 0) { + _rawAudioMicrophoneMix->setText("Mix RAW Song"); + } else { + _rawAudioMicrophoneMix->setText("Stop Mixing Song"); + } + +} void Application::updateFrustumRenderModeAction() { switch (_frustumDrawingMode) { diff --git a/interface/src/Application.h b/interface/src/Application.h index 4745196bf4..1e84de91e8 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -105,12 +105,12 @@ public: QNetworkAccessManager* getNetworkAccessManager() { return _networkAccessManager; } GeometryCache* getGeometryCache() { return &_geometryCache; } + + void resetSongMixMenuItem(); public slots: - void sendAvatarFaceVideoMessage(int frameCount, const QByteArray& data); - private slots: void timer(); diff --git a/interface/src/Audio.cpp b/interface/src/Audio.cpp index f5a6479985..3e011f5e05 100644 --- a/interface/src/Audio.cpp +++ b/interface/src/Audio.cpp @@ -154,7 +154,7 @@ inline void Audio::performIO(int16_t* inputLeft, int16_t* outputLeft, int16_t* o currentPacketPtr += sizeof(headOrientation); // check if we have a song to add to our audio - if (_songFileBytes > 0 && _songFileStream->tellg() <= _songFileBytes) { + if (_songFileBytes > 0 && _songFileStream->tellg() != -1) { // iterate over BUFFER_LENGTH_SAMPLES_PER_CHANNEL from the song file and add that to our audio for (int i = 0; i < BUFFER_LENGTH_SAMPLES_PER_CHANNEL; i++) { int16_t songSample = 0; @@ -180,6 +180,9 @@ inline void Audio::performIO(int16_t* inputLeft, int16_t* outputLeft, int16_t* o // reset the _songFileBytes back to zero _songFileBytes = 0; + + // call Application stopMixingSong method to fix menu item + Application::getInstance()->resetSongMixMenuItem(); } // copy the audio data to the last BUFFER_LENGTH_BYTES bytes of the data packet @@ -501,7 +504,6 @@ void Audio::importSongToMixWithMicrophone(const char* filename) { } void Audio::stopMixingSongWithMicrophone() { - qDebug("Stop mixing called!"); _songFileBytes = 0; }