Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor the engine to process samples in the range of [-1.0, 1.0]. Fixes Bug #1204039. #126

Merged
merged 9 commits into from
Dec 24, 2013

Conversation

rryan
Copy link
Member

@rryan rryan commented Dec 19, 2013

  • Move Vinyl Control pre-amp to VinylControlXwax (no longer affects
    microphone/passthrough).
  • Switch PortAudio input sample format to paFloat32.
  • Remove SHRT_MAX conversions on input and output samples.
  • Update VUMeters, clipping, and dithering code to deal with the new ranges.
  • Clean up EngineMicrophone/EnginePassthrough/EngineDeck handling of inputs.
  • Update tests to deal with the new sample ranges.

This does not change SoundSource. SoundSources still read 16-bit samples and we
simply divide by SHRT_MAX in AnalyserQueue and CachingReaderWorker. A future
performance improvement can remove this and use the native decoder API to
request normalized samples directly.

@ghost ghost assigned ywwg Dec 19, 2013
@rryan
Copy link
Member Author

rryan commented Dec 19, 2013

@ywwg could you please test that vinyl control still works? :)

@rryan
Copy link
Member Author

rryan commented Dec 19, 2013

Oops, I forgot shoutcast/recording.

@ywwg
Copy link
Member

ywwg commented Dec 19, 2013

I'll take a look

@rryan
Copy link
Member Author

rryan commented Dec 20, 2013

Thanks. The tests pass and the actual code changes are pretty non-controversial -- I just don't have a VC setup to test.

@ywwg
Copy link
Member

ywwg commented Dec 20, 2013

Debug [AnalyserQueue 1]: Beat calculation will not start
Debug [AnalyserQueue 1]: Track has previous key detection result that is not up to date with latest settings but user preferences indicate we should not re-analyze it.
Debug [AnalyserQueue 1]: Key calculation will not start.
Debug [AnalyserQueue 1]: Skipping track analysis because no analyzer initialized.
Debug [Main]: EngineSync::notifyPlaying "[Channel1]" true
Debug [VinylControlProcessor 1]: EngineSync::notifyBpmChanged "[Channel2]" 127.994
Debug [Main]: Committing transaction on "qt_sql_default_connection" result: true
Debug [Main]: PlaylistTableModel(0x21a8160) select() took 1 ms
Debug [VinylControlProcessor 1]: EngineSync::notifyPlaying "[Channel2]" true

Program received signal SIGFPE, Arithmetic exception.
[Switching to Thread 0x7fffc5add700 (LWP 1128)]
0x0000000000967b04 in VinylControlXwax::analyzeSamples (this=0x7fffb4002100, samples=, nFrames=) at src/vinylcontrol/vinylcontrolxwax.cpp:588
588 ringPos = (ringPos + 1) % iPitchRingSize;
(gdb) bt
#0 0x0000000000967b04 in VinylControlXwax::analyzeSamples (this=0x7fffb4002100, samples=, nFrames=)
at src/vinylcontrol/vinylcontrolxwax.cpp:588
#1 0x0000000000962d5a in VinylControlProcessor::run (this=0x121fd50) at src/vinylcontrol/vinylcontrolprocessor.cpp:102
#2 0x00007ffff5918f2f in ?? () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
#3 0x00007ffff371ef6e in start_thread (arg=0x7fffc5add700) at pthread_create.c:311
#4 0x00007ffff20849cd in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:113
(gdb) thread apply all bt

Thread 28 (Thread 0x7fff81bf5700 (LWP 1180)):
#0 pthread_cond_wait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185
#1 0x00007ffff5919406 in QWaitCondition::wait(QMutex*, unsigned long) () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
#2 0x00007ffff59155eb in QSemaphore::acquire(int) () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
#3 0x00000000004cb161 in CachingReaderWorker::run (this=0x5fac9d0) at src/cachingreaderworker.cpp:116
#4 0x00007ffff5918f2f in ?? () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
#5 0x00007ffff371ef6e in start_thread (arg=0x7fff81bf5700) at pthread_create.c:311
#6 0x00007ffff20849cd in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:113

Thread 27 (Thread 0x7fff823f6700 (LWP 1179)):
#0 pthread_cond_wait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185
#1 0x00007ffff5919406 in QWaitCondition::wait(QMutex*, unsigned long) () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
#2 0x00007ffff59155eb in QSemaphore::acquire(int) () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
#3 0x00000000004cb161 in CachingReaderWorker::run (this=0x33f5090) at src/cachingreaderworker.cpp:116
#4 0x00007ffff5918f2f in ?? () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
#5 0x00007ffff371ef6e in start_thread (arg=0x7fff823f6700) at pthread_create.c:311
#6 0x00007ffff20849cd in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:113

Thread 26 (Thread 0x7fff8b9a3700 (LWP 1140)):
#0 pthread_cond_timedwait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S:238
#1 0x00007ffff5917b7a in ?? () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
#2 0x00007ffff5918405 in QThread::usleep(unsigned long) () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
#3 0x00000000009843e8 in VSyncThread::run (this=0x224b1a0) at src/waveform/vsyncthread.cpp:73
#4 0x00007ffff5918f2f in ?? () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
#5 0x00007ffff371ef6e in start_thread (arg=0x7fff8b9a3700) at pthread_create.c:311
#6 0x00007ffff20849cd in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:113

Thread 25 (Thread 0x7fff99212700 (LWP 1139)):
#0 0x00007ffff2077f7d in poll () at ../sysdeps/unix/syscall-template.S:81
#1 0x00007ffff0abe6a4 in g_main_context_poll (priority=2147483647, n_fds=1, fds=0x7fffd40037e0, timeout=-1, context=0x7fffd4001d60)
at /build/buildd/glib2.0-2.38.1/./glib/gmain.c:4006
#2 g_main_context_iterate (context=context@entry=0x7fffd4001d60, block=block@entry=1, dispatch=dispatch@entry=1, self=)
at /build/buildd/glib2.0-2.38.1/./glib/gmain.c:3707
#3 0x00007ffff0abe7ac in g_main_context_iteration (context=0x7fffd4001d60, may_block=1) at /build/buildd/glib2.0-2.38.1/./glib/gmain.c:3773
#4 0x00007ffff5a45a55 in QEventDispatcherGlib::processEvents(QFlagsQEventLoop::ProcessEventsFlag) () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
#5 0x00007ffff5a175ef in QEventLoop::processEvents(QFlagsQEventLoop::ProcessEventsFlag) () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
#6 0x00007ffff5a178e5 in QEventLoop::exec(QFlagsQEventLoop::ProcessEventsFlag) () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
#7 0x00007ffff591688f in QThread::exec() () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
#8 0x00007ffff5918f2f in ?? () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
#9 0x00007ffff371ef6e in start_thread (arg=0x7fff99212700) at pthread_create.c:311
#10 0x00007ffff20849cd in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:113

---Type to continue, or q to quit---
Thread 24 (Thread 0x7fffde427700 (LWP 1138)):
#0 0x00007ffff2077f7d in poll () at ../sysdeps/unix/syscall-template.S:81
#1 0x00007ffff3307198 in ?? () from /lib/x86_64-linux-gnu/libusb-1.0.so.0
#2 0x00007ffff371ef6e in start_thread (arg=0x7fffde427700) at pthread_create.c:311
#3 0x00007ffff20849cd in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:113

Thread 23 (Thread 0x7fff99a13700 (LWP 1137)):
#0 pthread_cond_wait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185
#1 0x00007ffff5919406 in QWaitCondition::wait(QMutex*, unsigned long) () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
#2 0x00000000004ae9c9 in AnalyserQueue::dequeueNextBlocking (this=this@entry=0x21c8a10) at src/analyserqueue.cpp:94
#3 0x00000000004b0dfe in AnalyserQueue::run (this=0x21c8a10) at src/analyserqueue.cpp:264
#4 0x00007ffff5918f2f in ?? () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
#5 0x00007ffff371ef6e in start_thread (arg=0x7fff99a13700) at pthread_create.c:311
#6 0x00007ffff20849cd in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:113

Thread 22 (Thread 0x7fff9a214700 (LWP 1136)):
#0 pthread_cond_wait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185
#1 0x00007ffff5919406 in QWaitCondition::wait(QMutex*, unsigned long) () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
#2 0x0000000000775dfa in BrowseThread::run (this=0x1154d40) at src/library/browse/browsethread.cpp:82
#3 0x00007ffff5918f2f in ?? () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
#4 0x00007ffff371ef6e in start_thread (arg=0x7fff9a214700) at pthread_create.c:311
#5 0x00007ffff20849cd in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:113

Thread 21 (Thread 0x7fff9b4dc700 (LWP 1135)):
#0 pthread_cond_wait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185
#1 0x00007ffff5919406 in QWaitCondition::wait(QMutex*, unsigned long) () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
#2 0x00007ffff59155eb in QSemaphore::acquire(int) () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
#3 0x00000000004cb161 in CachingReaderWorker::run (this=0x1f40370) at src/cachingreaderworker.cpp:116
#4 0x00007ffff5918f2f in ?? () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
#5 0x00007ffff371ef6e in start_thread (arg=0x7fff9b4dc700) at pthread_create.c:311
#6 0x00007ffff20849cd in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:113

Thread 20 (Thread 0x7fffacd75700 (LWP 1134)):
#0 pthread_cond_wait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185
#1 0x00007ffff5919406 in QWaitCondition::wait(QMutex*, unsigned long) () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
#2 0x00007ffff59155eb in QSemaphore::acquire(int) () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
#3 0x00000000004cb161 in CachingReaderWorker::run (this=0x1d23930) at src/cachingreaderworker.cpp:116
#4 0x00007ffff5918f2f in ?? () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
#5 0x00007ffff371ef6e in start_thread (arg=0x7fffacd75700) at pthread_create.c:311
#6 0x00007ffff20849cd in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:113

Thread 19 (Thread 0x7fffae603700 (LWP 1133)):
#0 pthread_cond_wait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185
---Type to continue, or q to quit---
#1 0x00007ffff5919406 in QWaitCondition::wait(QMutex*, unsigned long) () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
#2 0x00007ffff59155eb in QSemaphore::acquire(int) () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
#3 0x00000000004cb161 in CachingReaderWorker::run (this=0x1b0f140) at src/cachingreaderworker.cpp:116
#4 0x00007ffff5918f2f in ?? () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
#5 0x00007ffff371ef6e in start_thread (arg=0x7fffae603700) at pthread_create.c:311
#6 0x00007ffff20849cd in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:113

Thread 18 (Thread 0x7fffafafe700 (LWP 1132)):
#0 pthread_cond_wait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185
#1 0x00007ffff5919406 in QWaitCondition::wait(QMutex*, unsigned long) () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
#2 0x00007ffff59155eb in QSemaphore::acquire(int) () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
#3 0x00000000004cb161 in CachingReaderWorker::run (this=0x18fa8a0) at src/cachingreaderworker.cpp:116
#4 0x00007ffff5918f2f in ?? () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
#5 0x00007ffff371ef6e in start_thread (arg=0x7fffafafe700) at pthread_create.c:311
#6 0x00007ffff20849cd in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:113

Thread 17 (Thread 0x7fffbd725700 (LWP 1131)):
#0 pthread_cond_wait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185
#1 0x00007ffff5919406 in QWaitCondition::wait(QMutex*, unsigned long) () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
#2 0x00007ffff59155eb in QSemaphore::acquire(int) () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
#3 0x00000000004cb161 in CachingReaderWorker::run (this=0x16e1f50) at src/cachingreaderworker.cpp:116
#4 0x00007ffff5918f2f in ?? () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
#5 0x00007ffff371ef6e in start_thread (arg=0x7fffbd725700) at pthread_create.c:311
#6 0x00007ffff20849cd in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:113

Thread 16 (Thread 0x7fffbefb3700 (LWP 1130)):
#0 pthread_cond_wait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185
#1 0x00007ffff5919406 in QWaitCondition::wait(QMutex*, unsigned long) () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
#2 0x00007ffff59155eb in QSemaphore::acquire(int) () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
#3 0x00000000004cb161 in CachingReaderWorker::run (this=0x14d4d50) at src/cachingreaderworker.cpp:116
#4 0x00007ffff5918f2f in ?? () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
#5 0x00007ffff371ef6e in start_thread (arg=0x7fffbefb3700) at pthread_create.c:311
#6 0x00007ffff20849cd in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:113

Thread 15 (Thread 0x7fffc4856700 (LWP 1129)):
#0 pthread_cond_wait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185
#1 0x00007ffff5919406 in QWaitCondition::wait(QMutex*, unsigned long) () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
#2 0x00007ffff59155eb in QSemaphore::acquire(int) () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
#3 0x00000000004cb161 in CachingReaderWorker::run (this=0x1269b60) at src/cachingreaderworker.cpp:116
#4 0x00007ffff5918f2f in ?? () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
#5 0x00007ffff371ef6e in start_thread (arg=0x7fffc4856700) at pthread_create.c:311
#6 0x00007ffff20849cd in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:113

---Type to continue, or q to quit---
Thread 14 (Thread 0x7fffc5add700 (LWP 1128)):
#0 0x0000000000967b04 in VinylControlXwax::analyzeSamples (this=0x7fffb4002100, samples=, nFrames=)
at src/vinylcontrol/vinylcontrolxwax.cpp:588
#1 0x0000000000962d5a in VinylControlProcessor::run (this=0x121fd50) at src/vinylcontrol/vinylcontrolprocessor.cpp:102
#2 0x00007ffff5918f2f in ?? () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
#3 0x00007ffff371ef6e in start_thread (arg=0x7fffc5add700) at pthread_create.c:311
#4 0x00007ffff20849cd in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:113

Thread 13 (Thread 0x7fffc7df2700 (LWP 1127)):
#0 0x00007ffff2077f7d in poll () at ../sysdeps/unix/syscall-template.S:81
#1 0x00007ffff1a856f6 in jack_cycle_wait () from /usr/lib/x86_64-linux-gnu/libjack.so.0
#2 0x00007ffff1a85a38 in ?? () from /usr/lib/x86_64-linux-gnu/libjack.so.0
#3 0x00007ffff371ef6e in start_thread (arg=0x7fffc7df2700) at pthread_create.c:311
#4 0x00007ffff20849cd in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:113

Thread 12 (Thread 0x7fffc6d05700 (LWP 1124)):
#0 pthread_cond_wait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185
#1 0x00007ffff1a86e33 in ?? () from /usr/lib/x86_64-linux-gnu/libjack.so.0
#2 0x00007ffff371ef6e in start_thread (arg=0x7fffc6d05700) at pthread_create.c:311
#3 0x00007ffff20849cd in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:113

Thread 7 (Thread 0x7fffdc891700 (LWP 1119)):
#0 pthread_cond_wait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185
#1 0x00007ffff5919406 in QWaitCondition::wait(QMutex*, unsigned long) () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
#2 0x0000000000707f8f in EngineSideChain::run (this=0x11803b0) at src/engine/sidechain/enginesidechain.cpp:93
#3 0x00007ffff5918f2f in ?? () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
#4 0x00007ffff371ef6e in start_thread (arg=0x7fffdc891700) at pthread_create.c:311
#5 0x00007ffff20849cd in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:113

Thread 6 (Thread 0x7fffdd425700 (LWP 1118)):
#0 pthread_cond_wait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185
#1 0x00007ffff5919406 in QWaitCondition::wait(QMutex*, unsigned long) () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
#2 0x00000000006ebf16 in EngineWorkerScheduler::run (this=0x1139a90) at src/engine/engineworkerscheduler.cpp:43
#3 0x00007ffff5918f2f in ?? () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
#4 0x00007ffff371ef6e in start_thread (arg=0x7fffdd425700) at pthread_create.c:311
#5 0x00007ffff20849cd in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:113

Thread 3 (Thread 0x7fffdec28700 (LWP 1114)):
#0 0x00007ffff2077f7d in poll () at ../sysdeps/unix/syscall-template.S:81
#1 0x00007ffff0abe6a4 in g_main_context_poll (priority=2147483647, n_fds=2, fds=0x7fffd00008c0, timeout=-1, context=0x10c04c0)
at /build/buildd/glib2.0-2.38.1/./glib/gmain.c:4006
#2 g_main_context_iterate (context=context@entry=0x10c04c0, block=block@entry=1, dispatch=dispatch@entry=1, self=)
at /build/buildd/glib2.0-2.38.1/./glib/gmain.c:3707
---Type to continue, or q to quit---
#3 0x00007ffff0abe7ac in g_main_context_iteration (context=0x10c04c0, may_block=may_block@entry=1) at /build/buildd/glib2.0-2.38.1/./glib/gmain.c:3773
#4 0x00007ffff0abe7f9 in glib_worker_main (data=) at /build/buildd/glib2.0-2.38.1/./glib/gmain.c:5472
#5 0x00007ffff0ae30f5 in g_thread_proxy (data=0x1026ed0) at /build/buildd/glib2.0-2.38.1/./glib/gthread.c:798
#6 0x00007ffff371ef6e in start_thread (arg=0x7fffdec28700) at pthread_create.c:311
#7 0x00007ffff20849cd in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:113

Thread 2 (Thread 0x7fffe015f700 (LWP 1113)):
#0 0x00007ffff2077f7d in poll () at ../sysdeps/unix/syscall-template.S:81
#1 0x00007ffff0abe6a4 in g_main_context_poll (priority=2147483647, n_fds=5, fds=0x7fffd8009c30, timeout=-1, context=0x104f0c0)
at /build/buildd/glib2.0-2.38.1/./glib/gmain.c:4006
#2 g_main_context_iterate (context=0x104f0c0, block=block@entry=1, dispatch=dispatch@entry=1, self=) at /build/buildd/glib2.0-2.38.1/./glib/gmain.c:3707
#3 0x00007ffff0abeb0a in g_main_loop_run (loop=0x104f050) at /build/buildd/glib2.0-2.38.1/./glib/gmain.c:3906
#4 0x00007fffe7b2ab66 in gdbus_shared_thread_func (user_data=0x104f090) at /build/buildd/glib2.0-2.38.1/./gio/gdbusprivate.c:278
#5 0x00007ffff0ae30f5 in g_thread_proxy (data=0x1026cf0) at /build/buildd/glib2.0-2.38.1/./glib/gthread.c:798
#6 0x00007ffff371ef6e in start_thread (arg=0x7fffe015f700) at pthread_create.c:311
#7 0x00007ffff20849cd in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:113

Thread 1 (Thread 0x7ffff7f967c0 (LWP 1099)):
#0 0x00007ffff6bd3ddc in QTextLine::layout_helper(int) () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
#1 0x00007ffff6abf806 in ?? () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
#2 0x00007ffff6ac042d in QPainter::drawText(QRect const&, int, QString const&, QRect_) () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
#3 0x00007ffff6cf9f2f in QCleanlooksStyle::drawItemText(QPainter_, QRect const&, int, QPalette const&, bool, QString const&, QPalette::ColorRole) const ()
from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
#4 0x00007ffff6d6d1b0 in QLabel::paintEvent(QPaintEvent_) () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
#5 0x00007ffff69c6104 in QWidget::event(QEvent_) () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
#6 0x00007ffff6d675be in QFrame::event(QEvent_) () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
#7 0x00007ffff6976dfc in QApplicationPrivate::notify_helper(QObject_, QEvent_) () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
#8 0x00007ffff697d470 in QApplication::notify(QObject_, QEvent_) () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
#9 0x00007ffff5a188bd in QCoreApplication::notifyInternal(QObject_, QEvent_) () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
#10 0x00007ffff69c0811 in QWidgetPrivate::drawWidget(QPaintDevice_, QRegion const&, QPoint const&, int, QPainter_, QWidgetBackingStore_) ()
from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
#11 0x00007ffff69c1240 in QWidgetPrivate::paintSiblingsRecursive(QPaintDevice_, QList<QObject_> const&, int, QRegion const&, QPoint const&, int, QPainter_, QWidgetBackingStore_) () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
#12 0x00007ffff69c03cc in QWidgetPrivate::drawWidget(QPaintDevice_, QRegion const&, QPoint const&, int, QPainter_, QWidgetBackingStore_) ()
from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
#13 0x00007ffff69c1240 in QWidgetPrivate::paintSiblingsRecursive(QPaintDevice_, QList<QObject*> const&, int, QRegion const&, QPoint const&, int, QPainter_, QWidgetBackingStore_) () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
#14 0x00007ffff69c10af in QWidgetPrivate::paintSiblingsRecursive(QPaintDevice_, QList<QObject_> const&, int, QRegion const&, QPoint const&, int, QPainter_, QWidgetBackingStore_) () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
#15 0x00007ffff69c03cc in QWidgetPrivate::drawWidget(QPaintDevice_, QRegion const&, QPoint const&, int, QPainter_, QWidgetBackingStore_) ()
from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
#16 0x00007ffff69c1240 in QWidgetPrivate::paintSiblingsRecursive(QPaintDevice_, QList<QObject*> const&, int, QRegion const&, QPoint const&, int, QPainter_, QWidgetBackingStore_) () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
---Type to continue, or q to quit---
#17 0x00007ffff69c03cc in QWidgetPrivate::drawWidget(QPaintDevice_, QRegion const&, QPoint const&, int, QPainter_, QWidgetBackingStore_) ()
from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
#18 0x00007ffff69c1240 in QWidgetPrivate::paintSiblingsRecursive(QPaintDevice_, QList<QObject*> const&, int, QRegion const&, QPoint const&, int, QPainter_, QWidgetBackingStore_) () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
#19 0x00007ffff69c03cc in QWidgetPrivate::drawWidget(QPaintDevice_, QRegion const&, QPoint const&, int, QPainter_, QWidgetBackingStore_) ()
from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
#20 0x00007ffff69c1240 in QWidgetPrivate::paintSiblingsRecursive(QPaintDevice_, QList<QObject*> const&, int, QRegion const&, QPoint const&, int, QPainter_, QWidgetBackingStore_) () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
#21 0x00007ffff69c03cc in QWidgetPrivate::drawWidget(QPaintDevice_, QRegion const&, QPoint const&, int, QPainter_, QWidgetBackingStore_) ()
from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
#22 0x00007ffff6b82f9e in ?? () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
#23 0x00007ffff69b5fc0 in QWidgetPrivate::syncBackingStore() () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
#24 0x00007ffff69c5c82 in QWidget::event(QEvent_) () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
#25 0x00007ffff6d7fdb3 in QMainWindow::event(QEvent_) () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
#26 0x00007ffff6976dfc in QApplicationPrivate::notify_helper(QObject_, QEvent_) () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
#27 0x00007ffff697d470 in QApplication::notify(QObject_, QEvent_) () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
#28 0x00007ffff5a188bd in QCoreApplication::notifyInternal(QObject_, QEvent_) () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
#29 0x00007ffff5a1be1f in QCoreApplicationPrivate::sendPostedEvents(QObject_, int, QThreadData*) () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
#30 0x00007ffff5a46073 in ?? () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
#31 0x00007ffff0abe3b6 in g_main_dispatch (context=0xefc1b0) at /build/buildd/glib2.0-2.38.1/./glib/gmain.c:3065
#32 g_main_context_dispatch (context=context@entry=0xefc1b0) at /build/buildd/glib2.0-2.38.1/./glib/gmain.c:3641
#33 0x00007ffff0abe708 in g_main_context_iterate (context=context@entry=0xefc1b0, block=block@entry=1, dispatch=dispatch@entry=1, self=)
at /build/buildd/glib2.0-2.38.1/./glib/gmain.c:3712
#34 0x00007ffff0abe7ac in g_main_context_iteration (context=0xefc1b0, may_block=1) at /build/buildd/glib2.0-2.38.1/./glib/gmain.c:3773
#35 0x00007ffff5a45a55 in QEventDispatcherGlib::processEvents(QFlagsQEventLoop::ProcessEventsFlag) () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
#36 0x00007ffff6a189d6 in ?? () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
#37 0x00007ffff5a175ef in QEventLoop::processEvents(QFlagsQEventLoop::ProcessEventsFlag) () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
#38 0x00007ffff5a178e5 in QEventLoop::exec(QFlagsQEventLoop::ProcessEventsFlag) () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
#39 0x00007ffff5a1ce5b in QCoreApplication::exec() () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
#40 0x000000000046e8aa in main (argc=4, argv=) at src/main.cpp:343
(gdb)

@ywwg
Copy link
Member

ywwg commented Dec 20, 2013

I will be going on vacation tomorrow so I may be slow in retesting

@ywwg
Copy link
Member

ywwg commented Dec 20, 2013

It is possible to test vinyl without a setup, although it's tricky:

  • download the serato CD wav file
  • start up JACK
  • start up a jack-rack, and add a simple amplifier
  • start up mixxx and set up deck 1 to output to the jack rack, and vinyl input 2 to input from the jack rack
  • set up deck 2 vinyl control to serato CD.
  • load the serato track in deck 1 and any track in deck 2.
  • enable vinyl control on deck 2
  • press play on deck 1

That will cause the samples from the serato CD to feed into the vinyl control input of deck 2, so deck 2 should start playing.

@rryan
Copy link
Member Author

rryan commented Dec 20, 2013

Hm. That segfault smells like we're writing past VinylControlXwax's m_pWorkBuffer and clobbering iPitchRingSize but analyzeSamples can never be called with nFrames > MAX_BUFFER_LEN/2 so that is confusing (m_pWorkBuffer is MAX_BUFFER_LEN shorts long).

@ywwg
Copy link
Member

ywwg commented Dec 20, 2013

The crash happens right when the play button illuminates so I suspect the pitch smoothing code.

@rryan
Copy link
Member Author

rryan commented Dec 20, 2013

Right -- iPitchRingSize is located 37-bytes (ish) past the end of m_pWorkBuffer in memory so it would be easy to clobber that to be 0 and cause the SIGFPE you saw.

…ixes Bug #1204039.

* Move Vinyl Control pre-amp to VinylControlXwax (no longer affects
  microphone/passthrough).

* Switch PortAudio input sample format to paFloat32.

* Remove SHRT_MAX conversions on input and output samples.

* Update VUMeters, clipping, and dithering code to deal with the new ranges.

* Clean up EngineMicrophone/EnginePassthrough/EngineDeck handling of inputs.

* Update tests to deal with the new sample ranges.

This does not change SoundSource. SoundSources still read 16-bit samples and we
simply divide by SHRT_MAX in AnalyserQueue and CachingReaderWorker. A future
performance improvement can remove this and use the native decoder API to
request normalized samples directly.
Conflicts:
	src/vinylcontrol/vinylcontrol.cpp
	src/vinylcontrol/vinylcontrol.h
	src/vinylcontrol/vinylcontrolxwax.cpp
	src/vinylcontrol/vinylcontrolxwax.h

bool bHaveSignal = fabs((float)samples[0]) + fabs((float)samples[1]) > MIN_SIGNAL;
bool bHaveSignal = fabs(pSamples[0]) + fabs(pSamples[1]) > MIN_SIGNAL;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note to self: Need to update MIN_SIGNAL to account for normalization.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@@ -102,9 +102,12 @@
m_iCrossFadeSamples(0),
m_iLastBufferSize(0) {

// Generate dither values
// Generate dither values. Before engine samples were normalized between
// [-1.0, 1.0], dithering values were in the range [-0.5, 0.5]. Now that we
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Weird phrasing in this comment?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It reads fine to me but maybe I'm missing something?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe the commas are making it confusing?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it sounds like we used to normalize between -1 and 1, but now we normalize from -1 to 1.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, yea that's meant to read "Before we did X, we did Y".

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-worded to something hopefully more clear.

@ywwg
Copy link
Member

ywwg commented Dec 24, 2013

I run my sound card at 24 bit resolution... is that something a) that we/pulseaudio even support, or b) would be affected by this change, for better or worse?

@rryan
Copy link
Member Author

rryan commented Dec 24, 2013

I believe this change should be good for 24-bit mode. Previously we took input as 16-bit PCM so PA would have to adapt from 24-bit to 16-bit PCM and we would convert from 16-bit PCM to float.

Now, PA converts from 24-bit PCM to [-1.0, 1.0] normalized floats when it delivers input to us and takes out [-1.0, 1.0] floats and converts them back to 24-bit PCM on output. Basically, we save a 16-bit -> 24-bit conversion.

In general (regardless of bit-depth your soundcard is using), this saves on a bunch of multiplying input and output by SHRT_MAX.

@rryan
Copy link
Member Author

rryan commented Dec 24, 2013

Any sign of that segfault you saw?

@ywwg
Copy link
Member

ywwg commented Dec 24, 2013

no sign of the segfault.

@ywwg
Copy link
Member

ywwg commented Dec 24, 2013

LGTM

rryan added a commit that referenced this pull request Dec 24, 2013
Refactor the engine to process samples in the range of [-1.0, 1.0]. Fixes Bug #1204039.
@rryan rryan merged commit e2b5e1c into mixxxdj:master Dec 24, 2013
@rryan rryan deleted the engine_refactor branch April 10, 2016 20:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants