diff --git a/core/audio_display.cpp b/core/audio_display.cpp index 573777c4e..ba8568e62 100644 --- a/core/audio_display.cpp +++ b/core/audio_display.cpp @@ -1201,7 +1201,7 @@ void AudioDisplay::OnMouseEvent(wxMouseEvent& event) { } // Stop scrubbing - bool scrubButton = false && event.ButtonIsDown(wxMOUSE_BTN_MIDDLE); + bool scrubButton = event.ButtonIsDown(wxMOUSE_BTN_MIDDLE); if (scrubbing && !scrubButton) { // Release mouse scrubbing = false; @@ -1214,7 +1214,7 @@ void AudioDisplay::OnMouseEvent(wxMouseEvent& event) { } // Start scrubbing - if (!scrubbing && scrubButton) { + if (!scrubbing && scrubButton && provider->GetChannels() == 1) { // Get mouse CaptureMouse(); scrubbing = true; @@ -1233,8 +1233,8 @@ void AudioDisplay::OnMouseEvent(wxMouseEvent& event) { // Scrub if (scrubbing && scrubButton) { // Get current data - __int64 curScrubPos = GetSampleAtX(x); - __int64 scrubDelta = scrubLastPos - curScrubPos; + __int64 curScrubPos = MAX(0,GetSampleAtX(x)); + __int64 scrubDelta = curScrubPos - scrubLastPos; int curScrubTime = clock(); int scrubDeltaTime = curScrubTime - scrubTime; @@ -1242,7 +1242,6 @@ void AudioDisplay::OnMouseEvent(wxMouseEvent& event) { if (scrubDelta != 0 && scrubDeltaTime > 0) { // Create buffer int bufSize = scrubDeltaTime * scrubProvider->GetSampleRate() / CLK_TCK; - scrubDelta = bufSize; short *buf = new short[bufSize]; // Flag as inverted, if necessary @@ -1254,25 +1253,25 @@ void AudioDisplay::OnMouseEvent(wxMouseEvent& event) { provider->GetAudio(temp,MIN(curScrubPos,scrubLastPos),scrubDelta); // Scale - //float scale = float(scrubDelta) / float(bufSize); - //float start,end; - //int istart,iend; - //float tempfinal; - //for (int i=0;i 0) { // Discard done if (startPos == BUFSIZE) { + delete buffer.front(); buffer.pop_front(); startPos = 0; } @@ -85,8 +87,8 @@ void StreamAudioProvider::GetAudio(void *buf, __int64 start, __int64 count) { if (isLast) size = endPos; // Write - toWrite = MIN(int(size-startPos),int(left)); - memcpy(((short*)buf)+written,&(buffer.front()->buf[startPos]),toWrite); + toWrite = MIN(size-startPos,int(left)); + memcpy(dst+written,&(buffer.front()->buf[startPos]),toWrite*2); startPos += toWrite; written += toWrite; left -= toWrite; @@ -99,7 +101,6 @@ void StreamAudioProvider::GetAudio(void *buf, __int64 start, __int64 count) { // Still left, fill with zero if (left > 0) { hasBuf = false; - short *dst = (short*) buf; for (__int64 i=written;i 0) { // Check space if (endPos == BUFSIZE) { @@ -123,7 +125,7 @@ void StreamAudioProvider::Append(void *src, __int64 count) { // Read toRead = MIN(int(BUFSIZE-endPos),int(left)); - memcpy(&(buffer.back()->buf[endPos]),((short*)src)+read,toRead); + memcpy(&(buffer.back()->buf[endPos]),src+read,toRead*2); endPos += toRead; read += toRead; buffered += toRead;