Chris@136: /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ Chris@136: Chris@136: /* Chris@136: Sonic Visualiser Chris@136: An audio file viewer and annotation editor. Chris@136: Centre for Digital Music, Queen Mary, University of London. Chris@202: This file copyright 2006 Chris Cannam and QMUL. Chris@136: Chris@136: This program is free software; you can redistribute it and/or Chris@136: modify it under the terms of the GNU General Public License as Chris@136: published by the Free Software Foundation; either version 2 of the Chris@136: License, or (at your option) any later version. See the file Chris@136: COPYING included with this distribution for more information. Chris@136: */ Chris@136: Chris@136: #ifndef _PREFERENCES_H_ Chris@136: #define _PREFERENCES_H_ Chris@136: Chris@136: #include "PropertyContainer.h" Chris@136: Chris@140: #include "Window.h" Chris@140: Chris@136: class Preferences : public PropertyContainer Chris@136: { Chris@136: Q_OBJECT Chris@136: Chris@136: public: Chris@156: static Preferences *getInstance(); Chris@136: Chris@136: virtual PropertyList getProperties() const; Chris@136: virtual QString getPropertyLabel(const PropertyName &) const; Chris@136: virtual PropertyType getPropertyType(const PropertyName &) const; Chris@245: virtual int getPropertyRangeAndValue(const PropertyName &, int *, int *, int *) const; Chris@136: virtual QString getPropertyValueLabel(const PropertyName &, int value) const; Chris@136: virtual QString getPropertyContainerName() const; Chris@136: virtual QString getPropertyContainerIconName() const; Chris@136: Chris@246: enum SpectrogramSmoothing { Chris@246: NoSpectrogramSmoothing, Chris@246: SpectrogramInterpolated, Chris@246: SpectrogramZeroPadded, Chris@246: SpectrogramZeroPaddedAndInterpolated Chris@246: }; Chris@246: Chris@553: enum SpectrogramXSmoothing { Chris@553: NoSpectrogramXSmoothing, Chris@553: SpectrogramXInterpolated Chris@553: }; Chris@553: Chris@246: SpectrogramSmoothing getSpectrogramSmoothing() const { return m_spectrogramSmoothing; } Chris@553: SpectrogramXSmoothing getSpectrogramXSmoothing() const { return m_spectrogramXSmoothing; } Chris@1038: double getTuningFrequency() const { return m_tuningFrequency; } Chris@140: WindowType getWindowType() const { return m_windowType; } Chris@136: Chris@1225: bool getRunPluginsInProcess() const { return m_runPluginsInProcess; } Chris@1225: Chris@138: //!!! harmonise with PaneStack Chris@138: enum PropertyBoxLayout { Chris@138: VerticallyStacked, Chris@138: Layered Chris@138: }; Chris@138: PropertyBoxLayout getPropertyBoxLayout() const { return m_propertyBoxLayout; } Chris@138: Chris@354: int getViewFontSize() const { return m_viewFontSize; } Chris@354: Chris@277: bool getOmitTempsFromRecentFiles() const { return m_omitRecentTemps; } Chris@277: Chris@297: QString getTemporaryDirectoryRoot() const { return m_tempDirRoot; } Chris@297: Chris@919: /// If we should always resample audio to the same rate, return it; otherwise (the normal case) return 0 Chris@1047: sv_samplerate_t getFixedSampleRate() const { return m_fixedSampleRate; } Chris@919: Chris@919: /// True if we should resample second or subsequent audio file to match first audio file's rate Chris@1313: bool getResampleOnLoad() const { return m_resampleOnLoad; } Chris@1313: Chris@1313: /// True if mp3 files should be loaded "gaplessly", i.e. compensating for encoder/decoder delay and padding Chris@1313: bool getUseGaplessMode() const { return m_gapless; } Chris@297: Chris@921: /// True if audio files should be loaded with normalisation (max == 1) Chris@921: bool getNormaliseAudio() const { return m_normaliseAudio; } Chris@921: Chris@297: enum BackgroundMode { Chris@297: BackgroundFromTheme, Chris@297: DarkBackground, Chris@297: LightBackground Chris@297: }; Chris@297: BackgroundMode getBackgroundMode() const { return m_backgroundMode; } Chris@297: Chris@612: enum TimeToTextMode { Chris@612: TimeToTextMs, Chris@612: TimeToTextUs, Chris@612: TimeToText24Frame, Chris@612: TimeToText25Frame, Chris@612: TimeToText30Frame, Chris@612: TimeToText50Frame, Chris@612: TimeToText60Frame Chris@612: }; Chris@612: TimeToTextMode getTimeToTextMode() const { return m_timeToTextMode; } Chris@612: Chris@1031: bool getShowHMS() const { return m_showHMS; } Chris@1031: Chris@892: int getOctaveOfMiddleC() const { Chris@892: // weed out unsupported octaves Chris@892: return getOctaveOfMiddleCInSystem(getSystemWithMiddleCInOctave(m_octave)); Chris@892: } Chris@892: int getOctaveOfLowestMIDINote() const { Chris@892: return getOctaveOfMiddleC() - 5; Chris@892: } Chris@892: Chris@372: bool getShowSplash() const { return m_showSplash; } Chris@372: Chris@136: public slots: Chris@136: virtual void setProperty(const PropertyName &, int); Chris@136: Chris@246: void setSpectrogramSmoothing(SpectrogramSmoothing smoothing); Chris@553: void setSpectrogramXSmoothing(SpectrogramXSmoothing smoothing); Chris@1038: void setTuningFrequency(double freq); Chris@138: void setPropertyBoxLayout(PropertyBoxLayout layout); Chris@140: void setWindowType(WindowType type); Chris@1225: void setRunPluginsInProcess(bool r); Chris@277: void setOmitTempsFromRecentFiles(bool omit); Chris@297: void setTemporaryDirectoryRoot(QString tempDirRoot); Chris@1047: void setFixedSampleRate(sv_samplerate_t); Chris@297: void setResampleOnLoad(bool); Chris@1313: void setUseGaplessMode(bool); Chris@921: void setNormaliseAudio(bool); Chris@297: void setBackgroundMode(BackgroundMode mode); Chris@612: void setTimeToTextMode(TimeToTextMode mode); Chris@1031: void setShowHMS(bool show); Chris@892: void setOctaveOfMiddleC(int oct); Chris@354: void setViewFontSize(int size); Chris@372: void setShowSplash(bool); Chris@136: Chris@136: private: Chris@145: Preferences(); // may throw DirectoryCreationFailed Chris@145: virtual ~Preferences(); Chris@136: Chris@136: static Preferences *m_instance; Chris@136: Chris@892: // We don't support arbitrary octaves in the gui, because we want Chris@892: // to be able to label what the octave system comes from. These Chris@892: // are the ones we support. (But we save and load as octave Chris@892: // numbers, so as not to make the prefs format really confusing) Chris@892: enum OctaveNumberingSystem { Chris@892: C0_Centre, Chris@892: C3_Logic, Chris@892: C4_ASA, Chris@892: C5_Sonar Chris@892: }; Chris@892: static int getOctaveOfMiddleCInSystem(OctaveNumberingSystem s); Chris@892: static OctaveNumberingSystem getSystemWithMiddleCInOctave(int o); Chris@892: Chris@246: SpectrogramSmoothing m_spectrogramSmoothing; Chris@553: SpectrogramXSmoothing m_spectrogramXSmoothing; Chris@1038: double m_tuningFrequency; Chris@138: PropertyBoxLayout m_propertyBoxLayout; Chris@140: WindowType m_windowType; Chris@1225: bool m_runPluginsInProcess; Chris@277: bool m_omitRecentTemps; Chris@297: QString m_tempDirRoot; Chris@1047: sv_samplerate_t m_fixedSampleRate; Chris@297: bool m_resampleOnLoad; Chris@1313: bool m_gapless; Chris@921: bool m_normaliseAudio; Chris@354: int m_viewFontSize; Chris@297: BackgroundMode m_backgroundMode; Chris@612: TimeToTextMode m_timeToTextMode; Chris@1031: bool m_showHMS; Chris@892: int m_octave; Chris@372: bool m_showSplash; Chris@136: }; Chris@136: Chris@136: #endif