mirror of
https://github.com/cookiengineer/audacity
synced 2025-12-17 14:11:13 +01:00
Stem Plot option when displaying samples
Initial commit.
This commit is contained in:
@@ -273,6 +273,7 @@ TrackArtist::TrackArtist()
|
|||||||
|
|
||||||
mdBrange = ENV_DB_RANGE;
|
mdBrange = ENV_DB_RANGE;
|
||||||
mShowClipping = false;
|
mShowClipping = false;
|
||||||
|
mSampleDisplay = 0;
|
||||||
UpdatePrefs();
|
UpdatePrefs();
|
||||||
|
|
||||||
SetColours();
|
SetColours();
|
||||||
@@ -1362,15 +1363,8 @@ void TrackArtist::DrawIndividualSamples(wxDC &dc, int leftOffset, const wxRect &
|
|||||||
rect.height, dB, true, dBRange, false)));
|
rect.height, dB, true, dBRange, false)));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw lines
|
|
||||||
for (decltype(slen) s = 0; s < slen - 1; s++) {
|
|
||||||
AColor::Line(dc,
|
|
||||||
rect.x + xpos[s], rect.y + ypos[s],
|
|
||||||
rect.x + xpos[s + 1], rect.y + ypos[s + 1]);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (showPoints)
|
if (showPoints) {
|
||||||
{
|
|
||||||
// Draw points where spacing is enough
|
// Draw points where spacing is enough
|
||||||
const int tickSize = bigPoints ? 4 : 3;// Bigger ellipses when draggable.
|
const int tickSize = bigPoints ? 4 : 3;// Bigger ellipses when draggable.
|
||||||
wxRect pr;
|
wxRect pr;
|
||||||
@@ -1387,6 +1381,28 @@ void TrackArtist::DrawIndividualSamples(wxDC &dc, int leftOffset, const wxRect &
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (showPoints && (mSampleDisplay == (int) WaveTrack::StemPlot)) {
|
||||||
|
// Draw vertical lines
|
||||||
|
int yZero = rect.y +
|
||||||
|
std::max(-1,
|
||||||
|
std::min(rect.height,
|
||||||
|
GetWaveYPos(0.0, zoomMin, zoomMax,
|
||||||
|
rect.height, dB, true, dBRange, false)));
|
||||||
|
for (decltype(slen) s = 0; s < slen; s++) {
|
||||||
|
AColor::Line(dc,
|
||||||
|
rect.x + xpos[s], rect.y + ypos[s],
|
||||||
|
rect.x + xpos[s], yZero);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// Connect samples with straight lines
|
||||||
|
for (decltype(slen) s = 0; s < slen - 1; s++) {
|
||||||
|
AColor::Line(dc,
|
||||||
|
rect.x + xpos[s], rect.y + ypos[s],
|
||||||
|
rect.x + xpos[s + 1], rect.y + ypos[s + 1]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Draw clipping
|
// Draw clipping
|
||||||
if (clipcnt) {
|
if (clipcnt) {
|
||||||
dc.SetPen(muted ? muteClippedPen : clippedPen);
|
dc.SetPen(muted ? muteClippedPen : clippedPen);
|
||||||
@@ -3202,6 +3218,7 @@ void TrackArtist::UpdatePrefs()
|
|||||||
{
|
{
|
||||||
mdBrange = gPrefs->Read(ENV_DB_KEY, mdBrange);
|
mdBrange = gPrefs->Read(ENV_DB_KEY, mdBrange);
|
||||||
mShowClipping = gPrefs->Read(wxT("/GUI/ShowClipping"), mShowClipping);
|
mShowClipping = gPrefs->Read(wxT("/GUI/ShowClipping"), mShowClipping);
|
||||||
|
gPrefs->Read(wxT("/GUI/SampleView"), &mSampleDisplay, 0);
|
||||||
SetColours();
|
SetColours();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -172,6 +172,7 @@ class AUDACITY_DLL_API TrackArtist {
|
|||||||
// Preference values
|
// Preference values
|
||||||
float mdBrange; // "/GUI/EnvdBRange"
|
float mdBrange; // "/GUI/EnvdBRange"
|
||||||
long mShowClipping; // "/GUI/ShowClipping"
|
long mShowClipping; // "/GUI/ShowClipping"
|
||||||
|
int mSampleDisplay; // "/GUI/SampleView"
|
||||||
bool mbShowTrackNameInWaveform; // "/GUI/ShowTrackNameInWaveform"
|
bool mbShowTrackNameInWaveform; // "/GUI/ShowTrackNameInWaveform"
|
||||||
|
|
||||||
int mInsetLeft;
|
int mInsetLeft;
|
||||||
|
|||||||
@@ -547,6 +547,13 @@ class AUDACITY_DLL_API WaveTrack final : public PlayableTrack {
|
|||||||
NoDisplay, // Preview track has no display
|
NoDisplay, // Preview track has no display
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Only two types of sample display for now, but
|
||||||
|
// others (eg sinc interpolation) may be added later.
|
||||||
|
enum SampleDisplay {
|
||||||
|
LinarInterpolate = 0,
|
||||||
|
StemPlot
|
||||||
|
};
|
||||||
|
|
||||||
// Read appropriate value from preferences
|
// Read appropriate value from preferences
|
||||||
static WaveTrackDisplay FindDefaultViewMode();
|
static WaveTrackDisplay FindDefaultViewMode();
|
||||||
|
|
||||||
|
|||||||
@@ -89,6 +89,15 @@ void TracksPrefs::Populate()
|
|||||||
mViewChoices.Add(_("Spectrogram"));
|
mViewChoices.Add(_("Spectrogram"));
|
||||||
mViewCodes.Add(WaveTrack::Spectrum);
|
mViewCodes.Add(WaveTrack::Spectrum);
|
||||||
|
|
||||||
|
|
||||||
|
// How samples are displayed when zoomed in:
|
||||||
|
|
||||||
|
mSampleDisplayChoice.Add(_("Connect dots"));
|
||||||
|
mSampleDisplayCodes.Add((int) WaveTrack::LinarInterpolate);
|
||||||
|
|
||||||
|
mSampleDisplayChoice.Add(_("Stem plot"));
|
||||||
|
mSampleDisplayCodes.Add((int) WaveTrack::StemPlot);
|
||||||
|
|
||||||
//------------------------- Main section --------------------
|
//------------------------- Main section --------------------
|
||||||
// Now construct the GUI itself.
|
// Now construct the GUI itself.
|
||||||
// Use 'eIsCreatingFromPrefs' so that the GUI is
|
// Use 'eIsCreatingFromPrefs' so that the GUI is
|
||||||
@@ -125,6 +134,13 @@ void TracksPrefs::PopulateOrExchange(ShuttleGui & S)
|
|||||||
mViewCodes);
|
mViewCodes);
|
||||||
S.SetSizeHints(mViewChoices);
|
S.SetSizeHints(mViewChoices);
|
||||||
|
|
||||||
|
S.TieChoice(_("Display samples:"),
|
||||||
|
wxT("/GUI/SampleView"),
|
||||||
|
0,
|
||||||
|
mSampleDisplayChoice,
|
||||||
|
mSampleDisplayCodes);
|
||||||
|
S.SetSizeHints(mSampleDisplayChoice);
|
||||||
|
|
||||||
S.TieTextBox(_("Default audio track &name:"),
|
S.TieTextBox(_("Default audio track &name:"),
|
||||||
wxT("/GUI/TrackNames/DefaultTrackName"),
|
wxT("/GUI/TrackNames/DefaultTrackName"),
|
||||||
_("Audio Track"),
|
_("Audio Track"),
|
||||||
|
|||||||
@@ -43,6 +43,8 @@ class TracksPrefs final : public PrefsPanel
|
|||||||
wxArrayString mSoloChoices;
|
wxArrayString mSoloChoices;
|
||||||
wxArrayInt mViewCodes;
|
wxArrayInt mViewCodes;
|
||||||
wxArrayString mViewChoices;
|
wxArrayString mViewChoices;
|
||||||
|
wxArrayInt mSampleDisplayCodes;
|
||||||
|
wxArrayString mSampleDisplayChoice;
|
||||||
};
|
};
|
||||||
|
|
||||||
class TracksPrefsFactory final : public PrefsPanelFactory
|
class TracksPrefsFactory final : public PrefsPanelFactory
|
||||||
|
|||||||
Reference in New Issue
Block a user