From 80984c9f1d77492eb85b5e2d6c0556e432a0327f Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Tue, 28 Mar 2017 15:50:07 -0400 Subject: [PATCH] From Pokechu22: Rename gain to velocity on note tracks "Velocity" is the technical term, and it's the term that's used everywhere. "Gain" was probably only used because "gain" is used on wave tracks; since note tracks aren't wave tracks (and shouldn't be treated as them) the corresponding variables should be named velocity. --- src/AudioIO.cpp | 2 +- src/MixerBoard.cpp | 4 ++-- src/NoteTrack.cpp | 8 ++++---- src/NoteTrack.h | 6 +++--- src/TrackPanel.cpp | 4 ++-- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/AudioIO.cpp b/src/AudioIO.cpp index 90afd7986..a740523cc 100644 --- a/src/AudioIO.cpp +++ b/src/AudioIO.cpp @@ -3790,7 +3790,7 @@ void AudioIO::OutputEvent() data1 = mNextEvent->get_pitch(); if (mNextIsNoteOn) { data2 = mNextEvent->get_loud(); // get velocity - int offset = mNextEventTrack->GetGain(); + int offset = mNextEventTrack->GetVelocity(); data2 += offset; // offset comes from per-track slider // clip velocity to insure a legal note-on value data2 = (data2 < 0 ? 1 : (data2 > 127 ? 127 : data2)); diff --git a/src/MixerBoard.cpp b/src/MixerBoard.cpp index 273465385..7da3ffd6e 100644 --- a/src/MixerBoard.cpp +++ b/src/MixerBoard.cpp @@ -395,7 +395,7 @@ void MixerTrackCluster::HandleSliderGain(const bool bWantPushState /*= false*/) mLeftTrack->SetGain(fValue); #ifdef EXPERIMENTAL_MIDI_OUT else - mNoteTrack->SetGain(fValue); + mNoteTrack->SetVelocity(fValue); #endif if (mRightTrack) mRightTrack->SetGain(fValue); @@ -512,7 +512,7 @@ void MixerTrackCluster::UpdateGain() #ifdef EXPERIMENTAL_MIDI_OUT if (mNoteTrack) { mSlider_Gain->SetStyle(VEL_SLIDER); - mSlider_Gain->Set(mNoteTrack->GetGain()); + mSlider_Gain->Set(mNoteTrack->GetVelocity()); return; } mSlider_Gain->SetStyle(DB_SLIDER); diff --git a/src/NoteTrack.cpp b/src/NoteTrack.cpp index 9f40661ee..9e0d0d0cb 100644 --- a/src/NoteTrack.cpp +++ b/src/NoteTrack.cpp @@ -113,7 +113,7 @@ Track(projDirManager) mSerializationLength = 0; #ifdef EXPERIMENTAL_MIDI_OUT - mGain = 0; + mVelocity = 0; #endif mBottomNote = 24; mPitchHeight = 5; @@ -160,7 +160,7 @@ Track::Holder NoteTrack::Duplicate() const duplicate->mVisibleChannels = mVisibleChannels; duplicate->SetOffset(GetOffset()); #ifdef EXPERIMENTAL_MIDI_OUT - duplicate->SetGain(GetGain()); + duplicate->SetVelocity(GetVelocity()); #endif // This std::move is needed to "upcast" the pointer type return std::move(duplicate); @@ -782,7 +782,7 @@ bool NoteTrack::HandleXMLTag(const wxChar *tag, const wxChar **attrs) else if (!wxStrcmp(attr, wxT("velocity")) && XMLValueChecker::IsGoodString(strValue) && Internat::CompatibleToDouble(strValue, &dblValue)) - mGain = (float) dblValue; + mVelocity = (float) dblValue; #endif else if (!wxStrcmp(attr, wxT("bottomnote")) && XMLValueChecker::IsGoodInt(strValue) && strValue.ToLong(&nValue)) @@ -838,7 +838,7 @@ void NoteTrack::WriteXML(XMLWriter &xmlFile) const xmlFile.WriteAttr(wxT("isSelected"), this->GetSelected()); #ifdef EXPERIMENTAL_MIDI_OUT - xmlFile.WriteAttr(wxT("velocity"), (double) saveme->mGain); + xmlFile.WriteAttr(wxT("velocity"), (double) saveme->mVelocity); #endif xmlFile.WriteAttr(wxT("bottomnote"), saveme->mBottomNote); xmlFile.WriteAttr(wxT("data"), wxString(data.str().c_str(), wxConvUTF8)); diff --git a/src/NoteTrack.h b/src/NoteTrack.h index 7ea8a0ccf..d6290f6ff 100644 --- a/src/NoteTrack.h +++ b/src/NoteTrack.h @@ -98,8 +98,8 @@ class AUDACITY_DLL_API NoteTrack final : public Track { bool Shift(double t) /* not override */; #ifdef EXPERIMENTAL_MIDI_OUT - float GetGain() const { return mGain; } - void SetGain(float gain) { mGain = gain; } + float GetVelocity() const { return mVelocity; } + void SetVelocity(float velocity) { mVelocity = velocity; } #endif double NearestBeatTime(double time, double *beat) const; @@ -202,7 +202,7 @@ class AUDACITY_DLL_API NoteTrack final : public Track { long mSerializationLength; #ifdef EXPERIMENTAL_MIDI_OUT - float mGain; // velocity offset + float mVelocity; // velocity offset #endif // mBottom is the Y offset of pitch 0 (normally off screen) diff --git a/src/TrackPanel.cpp b/src/TrackPanel.cpp index c977175c7..aaf840f8d 100644 --- a/src/TrackPanel.cpp +++ b/src/TrackPanel.cpp @@ -4963,7 +4963,7 @@ void TrackPanel::HandleSliders(wxMouseEvent &event, bool pan) // mCapturedTrack is not wave... if (!pan) { // .. so assume it is note - static_cast(mCapturedTrack)->SetGain(newValue); + static_cast(mCapturedTrack)->SetVelocity(newValue); #ifdef EXPERIMENTAL_MIXER_BOARD if (pMixerBoard) // probably should modify UpdateGain to take a track that is @@ -9377,7 +9377,7 @@ void TrackInfo::DrawVelocitySlider(wxDC *dc, NoteTrack *t, wxRect rect) const auto &gain = mGain; // mGains[index]; gain->SetStyle(VEL_SLIDER); GainSlider(index)->Move(wxPoint(gainRect.x, gainRect.y)); - GainSlider(index)->Set(t->GetGain()); + GainSlider(index)->Set(t->GetVelocity()); GainSlider(index)->OnPaint(*dc // , t->GetSelected() );