mixxxdj / mixxx

Mixxx is Free DJ software that gives you everything you need to perform live mixes.
http://mixxx.org
Other
4.47k stars 1.27k forks source link

Changing engaged Keylock/Pitch-B Engine during 96k playback issues + crash #11433

Open atskler opened 1 year ago

atskler commented 1 year ago

Bug Description

At samplerate 96kHz changing the engaged Keylock/Pitch-B Engine during playback speeds up the playback or crashes Mixxx, whatever happens first. Sometimes many switching required for the crash to happen.

The issue on video: https://www.youtube.com/watch?v=CY3o2nKhyCs

Version

2.4

OS

openSUSE Tumbleweed

atskler commented 1 year ago

The log files: 11433-konsole-output.txt 11433-mixxx.log

atskler commented 1 year ago

The problem does not happen at 44.1k.

Swiftb0y commented 1 year ago

In any case which results in a crash, we need a backtrace from you: https://github.com/mixxxdj/mixxx/wiki/Creating-Backtraces Thank you

Aryan-Mishra24 commented 1 year ago

i'd love to work on this issue or help and collaborate with whoever is working on it

Swiftb0y commented 1 year ago

@Aryan-Mishra24 I don't think anybody is working on this right now. As a first step towards investigating/fixing this, you can you try to reproduce this issue as outlined in the bug description.

atskler commented 1 year ago

In any case which results in a crash, we need a backtrace from you: https://github.com/mixxxdj/mixxx/wiki/Creating-Backtraces Thank you

Here it is:

11433-gdb-output.txt

Swiftb0y commented 1 year ago

Thank you, could be Rubberband, though I'm not sure since it could be mixxx fault passing invalid pointers or too large buffer sizes.

Crashing Thread 15

```cpp Thread 15 (Thread 0x7fffc6e746c0 (LWP 4738) "mixxx"): #0 0x00007ffff72d4929 in RubberBand::FFT::inverse(double const*, double const*, double*) () at /lib64/librubberband.so.2 #1 0x00007ffff72e5483 in RubberBand::R3Stretcher::synthesiseChannel(int, int, bool) () at /lib64/librubberband.so.2 #2 0x00007ffff72e6427 in RubberBand::R3Stretcher::consume() () at /lib64/librubberband.so.2 #3 0x00007ffff72ec080 in RubberBand::R3Stretcher::process(float const* const*, unsigned long, bool) () at /lib64/librubberband.so.2 #4 0x0000000000a8e5a2 in EngineBufferScaleRubberBand::deinterleaveAndProcess(float const*, long, bool) (flush=false, frames=246, pBuffer=, this=0x112c6130) at /usr/include/c++/13/array:276 available_samples = available_frames = 246 received_frames = next_block_frames_required = total_received_frames = 50 remaining_frames = 974 read = 0x7fffc554d1a0 last_read_failed = false break_out_after_retrieve_and_reset_rubberband = false #5 EngineBufferScaleRubberBand::scaleBuffer(float*, long) (this=0x112c6130, pOutputBuffer=, iOutputBufferSize=) at /home/atskler/Temporary/App-and-build/mixxx-rubberfix/mixxx/src/engine/bufferscalers/enginebufferscalerubberband.cpp:228 available_samples = available_frames = 246 received_frames = next_block_frames_required = total_received_frames = 50 remaining_frames = 974 read = 0x7fffc554d1a0 last_read_failed = false break_out_after_retrieve_and_reset_rubberband = false #6 0x0000000000a9791c in EngineBuffer::processTrackLocked(float*, int, mixxx::audio::SampleRate) (this=0x11ae2e90, pOutput=0x7fffc554d010, iBufferSize=2048, sampleRate=...) at /home/atskler/Temporary/App-and-build/mixxx-rubberfix/mixxx/src/engine/enginebuffer.cpp:1045 framesRead = t = {_vptr.ScopedTimer = 0x1060c70 , m_pTimer = 0x7fffc6e73040, m_timerMem = " \026=\204\377\177\000\000o\000\000\000\001\177\000\000\002\005\000\000\000\000\000\000\275G\216\035\000\000\000", m_cancel = false} baserate = pitchTempoRatio = {pitchRatio = 1, tempoRatio = 0.96392156862745093, pitchTweakRatio = 1, keylock = true} pitchRatio = 1 tempoRatio = keylock_enabled = is_scratching = false is_reverse = false speed = 0.96392156862745093 useIndependentPitchAndTempoScaling = rate = 0.44280147058823527 bCurBufferPaused = false atEnd = backwards = false trackEndPosition = {static kStartValue = 0, static kInvalidValue = nan(0x8000000000000), static kLegacyInvalidEnginePosition = -1, m_framePosition = } atStart = repeat_enabled = #7 0x0000000000a97d54 in EngineBuffer::process(float*, int) (this=0x11ae2e90, pOutput=0x7fffc554d010, iBufferSize=) at /home/atskler/Temporary/App-and-build/mixxx-rubberfix/mixxx/src/engine/enginebuffer.cpp:1145 #8 0x0000000000a90598 in EngineDeck::process(float*, int) (this=0x118357d0, pOut=0x7fffc554d010, iBufferSize=2048) at /home/atskler/Temporary/App-and-build/mixxx-rubberfix/mixxx/src/engine/channels/enginedeck.cpp:65 sampleBuffer = pEngineEffectsManager = #9 0x000000000071b1cb in EngineMaster::processChannels(int) (this=this@entry=0x116fa920, iBufferSize=iBufferSize@entry=2048) at /home/atskler/Temporary/App-and-build/mixxx-rubberfix/mixxx/src/engine/enginemaster.cpp:364 pChannelInfo = 0x11cac6f0 pChannel = 0x118357d0 i = 1 pLeaderChannel = activeChannelsStartIndex = #10 0x000000000071b763 in EngineMaster::process(int) (this=0x116fa920, iBufferSize=iBufferSize@entry=2048) at /home/atskler/Temporary/App-and-build/mixxx-rubberfix/mixxx/src/engine/enginemaster.cpp:413 haveSetName = true masterEnabled = true boothEnabled = false headphoneEnabled = false kChannels = 2 iFrames = 1024 pflMixGainInHeadphones = masterMixGainInHeadphones = busFeatures = {has_beat_length_sec = true, beat_length_sec = 4.2439915819305446e-314, has_beat_fraction = 192, beat_fraction = 6.9533084799682268e-310, has_gain = false, gain = -1.0079599106393273e+110} crossfaderLeftGain = 6.72623263e-44 crossfaderRightGain = 0 #11 0x0000000000592c6b in SoundManager::onDeviceOutputCallback(long) (this=, iFramesPerBuffer=iFramesPerBuffer@entry=1024) at /home/atskler/Temporary/App-and-build/mixxx-rubberfix/mixxx/src/soundio/soundmanager.cpp:591 #12 0x00000000008c7773 in SoundDevicePortAudio::callbackProcessClkRef(long, float*, float const*, PaStreamCallbackTimeInfo const*, unsigned long) (this=0x117bfda0, framesPerBuffer=1024, out=, in=, timeInfo=, statusFlags=) at /home/atskler/Temporary/App-and-build/mixxx-rubberfix/mixxx/src/soundio/sounddeviceportaudio.cpp:974 t = {_vptr.ScopedTimer = 0x1060c70 , m_pTimer = 0x7fffc6e733d0, m_timerMem = " \251\006\204\377\177\000\000o\000\000\000\001\000\000\000\002\005\000\000\000\000\000\000\333~\215\035\000\000\000", m_cancel = false} trace = {_vptr.Trace = 0x1061f08 , m_tag = {d = 0x7fff8406b510}, m_writeToStdout = false, m_time = true, m_timer = {t1 = 1282, t2 = 495807704}} #13 0x00007ffff7c9e2e5 in NonAdaptingProcess (bp=bp@entry=0x2f0cca60, streamCallbackResult=streamCallbackResult@entry=0x2f0ccc00, hostInputChannels=0x0, hostOutputChannels=0x2efdb220, framesToProcess=) at src/common/pa_process.c:873 userInput = userOutput = srcBytePtr = destBytePtr = srcSampleStrideSamples = srcChannelStrideBytes = destSampleStrideSamples = destChannelStrideBytes = i = frameCount = framesToGo = framesProcessed = 0 skipOutputConvert = 0 skipInputConvert = 0 #14 0x00007ffff7ca4959 in PaUtil_EndBufferProcessing (bp=bp@entry=0x2f0cca60, streamCallbackResult=streamCallbackResult@entry=0x2f0ccc00) at src/common/pa_process.c:1585 framesToProcess = framesToGo = framesProcessed = 0 __PRETTY_FUNCTION__ = "PaUtil_EndBufferProcessing" #15 0x00007ffff7ca4eb8 in RealProcess (frames=, stream=0x2f0cca10) at src/hostapi/jack/pa_jack.c:1467 chn = result = 0 timeInfo = {inputBufferAdcTime = 0, currentTime = 38.402510416666665, outputBufferDacTime = 38.434510416666662} framesProcessed = sr = cbFlags = paErr = result = 0 hostApi = 0x400 stream = 0x2f0cca10 xrun = 0 __PRETTY_FUNCTION__ = "JackCallback" #16 JackCallback (frames=1024, userData=userData@entry=0x9347cc0) at src/hostapi/jack/pa_jack.c:1608 paErr = result = 0 hostApi = 0x9347cc0 stream = 0x2f0cca10 xrun = 0 __PRETTY_FUNCTION__ = "JackCallback" #17 0x00007ffff2c3a7ad in Jack::JackClient::CallProcessCallback() (this=0x178a660) at ../common/JackClient.cpp:634 #18 Jack::JackClient::ExecuteThread() (this=0x178a660) at ../common/JackClient.cpp:598 #19 0x00007ffff2c3a478 in () at ../common/JackClient.h:220 #20 0x00007ffff2c56ebc in Jack::JackPosixThread::ThreadHandler(void*) (arg=0x178a8a8) at ../posix/JackPosixThread.cpp:63 obj = 0x178a8a8 runnable = 0x178a668 err = res = true #21 0x00007ffff30b2f24 in start_thread (arg=) at pthread_create.c:444 ret = pd = unwind_buf = {cancel_jmp_buf = {{jmp_buf = {140736530435288, -4584046582730150292, -312, 84, 140737488340192, 140736529907712, 4583613124501352044, 4583582510872309356}, mask_was_saved = 0}}, priv = {pad = {0x0, 0x0, 0x0, 0x0}, data = {prev = 0x0, cleanup = 0x0, canceltype = 0}}} not_first_call = #22 0x00007ffff3139f50 in clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:81 ```

ronso0 commented 1 year ago

I also noticed the sudden pitch change recently and I always use 48 kHz. IIRC my personal branch is based on 2.4

Aryan-Mishra24 commented 1 year ago

I suppose a condition block for 96kHz sample rate is the way to go we'll need to make sure that the engine switch is done safely to prevent crashes or playback speed issues. This might involve stopping the playback, switching the engine, and then resuming the playback It's hard for me to Locate the source file responsible for handling the Keylock/Pitch-B Engine

Aryan-Mishra24 commented 1 year ago

Apologies for taking 4 hours to reply it was midnight in India when i got the ping but luckily I'm an early bird

ronso0 commented 1 year ago

@Aryan-Mishra24 Don't worry :tea: no one is expecting this to be resolved in hours

Aryan-Mishra24 commented 1 year ago

What is the path to the files for the keylock feature

ronso0 commented 1 year ago

The original ControlObject [Master], keylock_engine is created in src/engine/enginemaster.cpp but the value changes are computed in src/engine/enginebuffer.cpp Just search src/ for "keylock_engine"

Aryan-Mishra24 commented 1 year ago

bit off more than i could chew , choked, coughed it out, made the outline for the " engine switch is done safely to prevent crashes or playback speed issues. This might involve stopping the playback, switching the engine, and then resuming the playback" but then got lost as to how to properly implement that functionality and what are the relevant functions to that operation @ronso0 was right " no one is expecting this to be resolved in hours" and neither should i