diff --git a/src/exam/texamexecutor.cpp b/src/exam/texamexecutor.cpp index 6c925f6dcd956718afc33f4455727a81628e7cce..e02ab2a6e60eb2ed2d4c92921ea42078ab0529a4 100755 --- a/src/exam/texamexecutor.cpp +++ b/src/exam/texamexecutor.cpp @@ -312,6 +312,12 @@ void TexamExecutor::askQuestion(bool isAttempt) { curQ->lastAttempt()->melodyWasPlayed(); // it was played once for sure if (m_exercise) m_melody->clearToFix(melodyLength); + // melody debug output +// QStringList notes; +// for (int i = 0; i < curQ->melody()->length(); ++i) +// notes << curQ->melody()->note(i)->p().toText(); +// qDebug() << "\n[TexamExecutor] Question" << m_exam->count() << "attempt" << curQ->attemptsCount(); +// qDebug() << "Melody" << notes; } // qDebug() << curQ->qa.note.toText() << "Q" << (int)curQ->questionAs // << "A" << (int)curQ->answerAs << curQ->key.getName() @@ -1271,7 +1277,7 @@ void TexamExecutor::stopExamSlot() { void TexamExecutor::closeExecutor() { mW->setMessageBg(-1); - mW->setStatusMessage(""); + mW->setStatusMessage(QString()); mW->setStatusMessage(tr("Such a pity."), 5000); m_canvas->clearCanvas(); @@ -1350,7 +1356,7 @@ bool TexamExecutor::closeNootka() { } delete msg; } - return result; + return result; } @@ -1400,6 +1406,8 @@ void TexamExecutor::connectPlayingFinished() { void TexamExecutor::noteOfMelodyStarted(const TnoteStruct& n) { +// Tnote nn = n.pitch; +// qDebug() << "[TexamExecutor] note started" << nn.toText(); if (m_melody->wasIndexChanged()) m_exam->curQ()->lastAttempt()->melodyWasPlayed(); m_melody->noteStarted(); @@ -1411,6 +1419,8 @@ void TexamExecutor::noteOfMelodyStarted(const TnoteStruct& n) { void TexamExecutor::noteOfMelodyFinished(const TnoteStruct& n) { +// Tnote nn = n.pitch; +// qDebug() << "[TexamExecutor] note finished" << nn.toText(); m_melody->setNote(n); if (m_melody->currentIndex() == m_exam->curQ()->melody()->length() - 1) { if (gl->E->expertsAnswerEnable) diff --git a/src/libs/sound/tpitchfinder.cpp b/src/libs/sound/tpitchfinder.cpp index 180a426a5aa01f8b5a39380945379e5d7dff4909..11b8253a641c9938206b7983be9bebb957f6f81c 100644 --- a/src/libs/sound/tpitchfinder.cpp +++ b/src/libs/sound/tpitchfinder.cpp @@ -94,7 +94,6 @@ TpitchFinder::TpitchFinder(QObject* parent) : TpitchFinder::~TpitchFinder() { - qDebug() << "[TpitchFinder] deleting...."; m_doProcess = false; m_mutex.lock(); m_mutex.unlock(); @@ -107,7 +106,6 @@ TpitchFinder::~TpitchFinder() delete m_aGl; delete m_thread; delete m_tokenBuffer; - qDebug() << "[TpitchFinder] deleted"; } //########################################################################################################## diff --git a/src/libs/sound/trtaudio.cpp b/src/libs/sound/trtaudio.cpp index b84b94a4edcdfe5459f3a1d94d8a4cea12c52ab3..d2eda75cd1379e385a27ec6e2f960a06329edddc 100755 --- a/src/libs/sound/trtaudio.cpp +++ b/src/libs/sound/trtaudio.cpp @@ -78,7 +78,7 @@ void TrtAudio::createRtAudio() { m_rtAduio = new RtAudio(rtAPI); m_rtAduio->showWarnings(false); } catch (RtAudioError& e) { - qDebug() << "Cannot create RtAudio instance" << QString::fromStdString(e.getMessage()); + qDebug() << "[TrtAudio] Cannot create RtAudio instance" << QString::fromStdString(e.getMessage()); m_rtAduio = 0; } } @@ -155,7 +155,7 @@ void TrtAudio::printSupportedFormats(RtAudio::DeviceInfo& devInfo) { fmt += " RTAUDIO_FLOAT32"; if (devInfo.nativeFormats & 0x20) fmt += " RTAUDIO_FLOAT64"; - qDebug() << "supported sample formats:" << fmt; + qDebug() << "[TrtAudio] supported sample formats:" << fmt; } @@ -163,7 +163,7 @@ void TrtAudio::printSupportedSampleRates(RtAudio::DeviceInfo& devInfo) { QString sRates; for (int i = 0; i < devInfo.sampleRates.size(); i++) sRates += QString("%1 ").arg(devInfo.sampleRates.at(i)); - qDebug() << "supported sample rates:"<< sRates; + qDebug() << "[TrtAudio] supported sample rates:"<< sRates; } @@ -253,7 +253,7 @@ void TrtAudio::updateAudioParams() { RtAudio::DeviceInfo inputInfo; getDeviceInfo(inputInfo, inDevId); if (inputInfo.inputChannels <= 0) { - qDebug("wrong default input device"); + qDebug("[TrtAudio] wrong default input device"); deleteInParams(); } } @@ -266,7 +266,7 @@ void TrtAudio::updateAudioParams() { getDeviceInfo(outInfo, outDevId); if (outDevId > -1) { if (outInfo.outputChannels <= 0) { - qDebug("wrong default output device"); + qDebug("[TrtAudio] wrong default output device"); deleteOutParams(); } } @@ -282,7 +282,7 @@ void TrtAudio::updateAudioParams() { outDevId = 0; } } else { - qDebug() << "No audio devices!"; + qDebug() << "[TrtAudio] No audio devices!"; return; } // setting device parameters @@ -338,7 +338,7 @@ bool TrtAudio::listen() { } m_state = e_listening; rtDevice()->openStream(0, m_inParams, RTAUDIO_SINT16, m_inSR, &m_bufferFrames, &listenCallBack, 0, streamOptions); -// qDebug() << "stream is listening"; +// qDebug() << "[TrtAudio] stream is listening"; return true; } @@ -354,7 +354,7 @@ bool TrtAudio::play() { } m_state = e_playing; rtDevice()->openStream(m_outParams, 0, RTAUDIO_SINT16, m_outSR, &m_bufferFrames, &playCallBack, 0, streamOptions); -// qDebug() << "stream is playing"; +// qDebug() << "[TrtAudio] stream is playing"; return true; } @@ -370,12 +370,12 @@ bool TrtAudio::openStream() { else splitTry = play(); if (!splitTry) { - qDebug() << "Cannot open split stream"; + qDebug() << "[TrtAudio] Cannot open split stream"; return false; } } else if (!rtDevice()->isStreamOpen()) { rtDevice()->openStream(m_outParams, m_inParams, RTAUDIO_SINT16, sampleRate(), &m_bufferFrames, m_callBack, 0, streamOptions); - qDebug() << "audio opened in duplex mode"; + qDebug() << "[TrtAudio] audio opened in duplex mode"; } if (rtDevice()->isStreamOpen()) { @@ -404,7 +404,7 @@ bool TrtAudio::openStream() { return false; } } catch (RtAudioError& e) { - qDebug() << "can't open stream" << m_inDevName << m_outDevName << "\n" << QString::fromStdString(e.getMessage()); + qDebug() << "[TrtAudio] can't open stream" << m_inDevName << m_outDevName << "\n" << QString::fromStdString(e.getMessage()); return false; } return true; @@ -427,13 +427,12 @@ bool TrtAudio::startStream() { try { if (rtDevice() && !rtDevice()->isStreamRunning()) { rtDevice()->startStream(); -// qDebug("stream started"); } } catch (RtAudioError& e) { - qDebug() << "can't start stream"; - return false; + qDebug() << "[TrtAudio] can't start stream"; + return false; } -// qDebug("stream started"); +// qDebug("[TrtAudio] stream started"); return true; } @@ -442,10 +441,10 @@ void TrtAudio::stopStream() { try { if (rtDevice() && rtDevice()->isStreamRunning()) { rtDevice()->stopStream(); -// qDebug("stream stopped"); +// qDebug("[TrtAudio] stream stopped"); } } catch (RtAudioError& e) { - qDebug() << "can't stop stream"; + qDebug() << "[TrtAudio] can't stop stream"; } } @@ -456,10 +455,10 @@ void TrtAudio::closeStream() { if (rtDevice() && rtDevice()->isStreamOpen()) { rtDevice()->closeStream(); m_state = e_iddle; -// qDebug("stream closed"); +// qDebug("[TrtAudio] stream closed"); } } catch (RtAudioError& e) { - qDebug() << "can't close stream"; + qDebug() << "[TrtAudio] can't close stream"; } } @@ -468,11 +467,11 @@ void TrtAudio::abortStream() { try { if (rtDevice() && rtDevice()->isStreamRunning()) { rtDevice()->abortStream(); -// qDebug("stream aborted"); +// qDebug("[TrtAudio] stream aborted"); } } catch (RtAudioError& e) { - qDebug() << "can't abort stream"; + qDebug() << "[TrtAudio] can't abort stream"; } if (areStreamsSplit()) closeStream(); @@ -511,7 +510,7 @@ bool TrtAudio::getDeviceInfo(RtAudio::DeviceInfo& devInfo, int id) { devInfo = rtDevice()->getDeviceInfo(id); } catch (RtAudioError& e) { - qDebug() << "error when probing audio device" << id; + qDebug() << "[TrtAudio] error when probing audio device" << id; return false; } return true; @@ -525,7 +524,7 @@ RtAudio::Api TrtAudio::getCurrentApi() { api = rtDevice()->getCurrentApi(); } catch (RtAudioError& e) { - qDebug() << "Cannot determine current API";; + qDebug() << "[TrtAudio] Cannot determine current API";; } } return api; @@ -539,7 +538,7 @@ unsigned int TrtAudio::getDeviceCount() { cnt = rtDevice()->getDeviceCount(); } catch (RtAudioError& e) { - qDebug() << "Cannot obtain devices number"; + qDebug() << "[TrtAudio] Cannot obtain devices number"; } } return cnt; @@ -553,7 +552,7 @@ int TrtAudio::getDefaultIn() { inNr = rtDevice()->getDefaultInputDevice(); } catch (RtAudioError& e) { - qDebug() << "Cannot get default input device"; + qDebug() << "[TrtAudio] Cannot get default input device"; } } return inNr; @@ -567,7 +566,7 @@ int TrtAudio::getDefaultOut() { inNr = rtDevice()->getDefaultOutputDevice(); } catch (RtAudioError& e) { - qDebug() << "Cannot get default output device"; + qDebug() << "[TrtAudio] Cannot get default output device"; } } return inNr; diff --git a/src/libs/sound/trtaudioin.cpp b/src/libs/sound/trtaudioin.cpp index 1601e7d3f9632e0d78d7523f153adf857b409904..38a376c94a16ae0e4b59e2660f3301ce8e68d338 100755 --- a/src/libs/sound/trtaudioin.cpp +++ b/src/libs/sound/trtaudioin.cpp @@ -129,23 +129,25 @@ void TaudioIN::setMinimalVolume(float minVol) { } -/** Range of notes is increased semitone down and up. - * This 46 and 48 are its sign. - * Normally 47 is offset of midi note to Nootka Tnote. */ +/** + * Range of notes is increased semitone down and up. + * This 46 and 48 are its sign. + * Normally 47 is offset of midi note to Nootka Tnote. +*/ void TaudioIN::setAmbitus(Tnote loNote, Tnote hiNote) { m_loPitch = loNote.toMidi() - 1; m_hiPitch = hiNote.toMidi() + 1; m_loNote = loNote; m_hiNote = hiNote; - TpitchFinder::Erange range = TpitchFinder::e_middle; - if (loNote.chromatic() > Tnote(6, 0, 0).chromatic()) - range = TpitchFinder::e_high; - else if (loNote.chromatic() > Tnote(5, -2, 0).chromatic()) - range = TpitchFinder::e_middle; - else - range = TpitchFinder::e_low; - if ((int)range != m_currentRange) { - m_currentRange = (int)range; + TpitchFinder::Erange range = loNote.chromatic() > Tnote(5, -2, 0).chromatic() ? TpitchFinder::e_middle : TpitchFinder::e_low; +// if (loNote.chromatic() > Tnote(6, 0, 0).chromatic()) +// range = TpitchFinder::e_high; +// else if (loNote.chromatic() > Tnote(5, -2, 0).chromatic()) +// range = TpitchFinder::e_middle; +// else +// range = TpitchFinder::e_low; + if (static_cast<int>(range) != m_currentRange) { + m_currentRange = static_cast<int>(range); bool isStop = isStoped(); stopListening(); m_pitch->setSampleRate(m_pitch->aGl()->rate, m_currentRange); @@ -189,7 +191,7 @@ void TaudioIN::startListening() { openStream(); if (startStream()) setState(e_listening); - qDebug() << "start listening"; +// qDebug() << "start listening"; } } } @@ -197,7 +199,7 @@ void TaudioIN::startListening() { void TaudioIN::stopListening() { if (state() != e_stopped) { - qDebug() << "stop listening"; +// qDebug() << "stop listening"; m_volume = 0.0; m_LastChunkPitch = 0.0; if (areStreamsSplit() || rtDevice()->getCurrentApi() != RtAudio::LINUX_PULSE) @@ -211,8 +213,8 @@ void TaudioIN::stopListening() { void TaudioIN::pitchInChunkSlot(float pitch) { if (isPaused()) return; - if (pitch == 0.0) - m_LastChunkPitch = 0.0; + if (pitch == 0.0f) + m_LastChunkPitch = 0.0f; else m_LastChunkPitch = pitch - audioParams()->a440diff; } @@ -223,8 +225,10 @@ void TaudioIN::noteStartedSlot(qreal pitch, qreal freq, qreal duration) { m_lastNote.set(pitch - audioParams()->a440diff, freq, duration); if (inRange(m_lastNote.pitchF)) { m_noteWasStarted = true; +// qDebug() << "[TaudioIN] started" << pitch << m_lastNote.pitch.toText(); emit noteStarted(m_lastNote); - } + } // else +// qDebug() << "[TaudioIN] started but out of range"; } else m_lastNote.set(); // reset last detected note structure } @@ -236,8 +240,10 @@ void TaudioIN::noteFinishedSlot(TnoteStruct* lastNote) { qreal midiPitch = lastNote->getAverage(3, // non guitar pitch is average of all pitches Tcore::gl()->instrument == e_noInstrument ? lastNote->pitches()->size() : m_pitch->minChunksNumber()); m_lastNote.set(midiPitch - audioParams()->a440diff, pitch2freq(midiPitch), lastNote->duration); - if (inRange(m_lastNote.pitchF)) + if (inRange(m_lastNote.pitchF)) { +// qDebug() << "[TaudioIN] finished" << m_lastNote.pitchF << m_lastNote.pitch.toText(); emit noteFinished(m_lastNote); + } } else m_lastNote.set(); // reset last detected note structure }