mirror of
https://github.com/cookiengineer/audacity
synced 2025-09-17 16:50:26 +02:00
Stem Plot option when displaying samples
Initial commit.
This commit is contained in:
parent
7f98672e22
commit
53a64757e7
@ -273,6 +273,7 @@ TrackArtist::TrackArtist()
|
||||
|
||||
mdBrange = ENV_DB_RANGE;
|
||||
mShowClipping = false;
|
||||
mSampleDisplay = 0;
|
||||
UpdatePrefs();
|
||||
|
||||
SetColours();
|
||||
@ -1362,15 +1363,8 @@ void TrackArtist::DrawIndividualSamples(wxDC &dc, int leftOffset, const wxRect &
|
||||
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
|
||||
const int tickSize = bigPoints ? 4 : 3;// Bigger ellipses when draggable.
|
||||
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
|
||||
if (clipcnt) {
|
||||
dc.SetPen(muted ? muteClippedPen : clippedPen);
|
||||
@ -3202,6 +3218,7 @@ void TrackArtist::UpdatePrefs()
|
||||
{
|
||||
mdBrange = gPrefs->Read(ENV_DB_KEY, mdBrange);
|
||||
mShowClipping = gPrefs->Read(wxT("/GUI/ShowClipping"), mShowClipping);
|
||||
gPrefs->Read(wxT("/GUI/SampleView"), &mSampleDisplay, 0);
|
||||
SetColours();
|
||||
}
|
||||
|
||||
|
@ -172,6 +172,7 @@ class AUDACITY_DLL_API TrackArtist {
|
||||
// Preference values
|
||||
float mdBrange; // "/GUI/EnvdBRange"
|
||||
long mShowClipping; // "/GUI/ShowClipping"
|
||||
int mSampleDisplay; // "/GUI/SampleView"
|
||||
bool mbShowTrackNameInWaveform; // "/GUI/ShowTrackNameInWaveform"
|
||||
|
||||
int mInsetLeft;
|
||||
|
@ -547,6 +547,13 @@ class AUDACITY_DLL_API WaveTrack final : public PlayableTrack {
|
||||
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
|
||||
static WaveTrackDisplay FindDefaultViewMode();
|
||||
|
||||
|
@ -89,6 +89,15 @@ void TracksPrefs::Populate()
|
||||
mViewChoices.Add(_("Spectrogram"));
|
||||
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 --------------------
|
||||
// Now construct the GUI itself.
|
||||
// Use 'eIsCreatingFromPrefs' so that the GUI is
|
||||
@ -125,6 +134,13 @@ void TracksPrefs::PopulateOrExchange(ShuttleGui & S)
|
||||
mViewCodes);
|
||||
S.SetSizeHints(mViewChoices);
|
||||
|
||||
S.TieChoice(_("Display samples:"),
|
||||
wxT("/GUI/SampleView"),
|
||||
0,
|
||||
mSampleDisplayChoice,
|
||||
mSampleDisplayCodes);
|
||||
S.SetSizeHints(mSampleDisplayChoice);
|
||||
|
||||
S.TieTextBox(_("Default audio track &name:"),
|
||||
wxT("/GUI/TrackNames/DefaultTrackName"),
|
||||
_("Audio Track"),
|
||||
|
@ -43,6 +43,8 @@ class TracksPrefs final : public PrefsPanel
|
||||
wxArrayString mSoloChoices;
|
||||
wxArrayInt mViewCodes;
|
||||
wxArrayString mViewChoices;
|
||||
wxArrayInt mSampleDisplayCodes;
|
||||
wxArrayString mSampleDisplayChoice;
|
||||
};
|
||||
|
||||
class TracksPrefsFactory final : public PrefsPanelFactory
|
||||
|
Loading…
x
Reference in New Issue
Block a user