svcore  1.9
Preferences.h
Go to the documentation of this file.
00001 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*-  vi:set ts=8 sts=4 sw=4: */
00002 
00003 /*
00004     Sonic Visualiser
00005     An audio file viewer and annotation editor.
00006     Centre for Digital Music, Queen Mary, University of London.
00007     This file copyright 2006 Chris Cannam and QMUL.
00008     
00009     This program is free software; you can redistribute it and/or
00010     modify it under the terms of the GNU General Public License as
00011     published by the Free Software Foundation; either version 2 of the
00012     License, or (at your option) any later version.  See the file
00013     COPYING included with this distribution for more information.
00014 */
00015 
00016 #ifndef _PREFERENCES_H_
00017 #define _PREFERENCES_H_
00018 
00019 #include "PropertyContainer.h"
00020 
00021 #include "Window.h"
00022 
00023 class Preferences : public PropertyContainer
00024 {
00025     Q_OBJECT
00026 
00027 public:
00028     static Preferences *getInstance();
00029 
00030     virtual PropertyList getProperties() const;
00031     virtual QString getPropertyLabel(const PropertyName &) const;
00032     virtual PropertyType getPropertyType(const PropertyName &) const;
00033     virtual int getPropertyRangeAndValue(const PropertyName &, int *, int *, int *) const;
00034     virtual QString getPropertyValueLabel(const PropertyName &, int value) const;
00035     virtual QString getPropertyContainerName() const;
00036     virtual QString getPropertyContainerIconName() const;
00037 
00038     enum SpectrogramSmoothing {
00039         NoSpectrogramSmoothing,
00040         SpectrogramInterpolated,
00041         SpectrogramZeroPadded,
00042         SpectrogramZeroPaddedAndInterpolated
00043     };
00044 
00045     enum SpectrogramXSmoothing {
00046         NoSpectrogramXSmoothing,
00047         SpectrogramXInterpolated
00048     };
00049 
00050     SpectrogramSmoothing getSpectrogramSmoothing() const { return m_spectrogramSmoothing; }
00051     SpectrogramXSmoothing getSpectrogramXSmoothing() const { return m_spectrogramXSmoothing; }
00052     float getTuningFrequency() const { return m_tuningFrequency; }
00053     WindowType getWindowType() const { return m_windowType; }
00054     int getResampleQuality() const { return m_resampleQuality; }
00055 
00057     enum PropertyBoxLayout {
00058         VerticallyStacked,
00059         Layered
00060     };
00061     PropertyBoxLayout getPropertyBoxLayout() const { return m_propertyBoxLayout; }
00062 
00063     int getViewFontSize() const { return m_viewFontSize; }
00064 
00065     bool getOmitTempsFromRecentFiles() const { return m_omitRecentTemps; }
00066 
00067     QString getTemporaryDirectoryRoot() const { return m_tempDirRoot; }
00068 
00070     int getFixedSampleRate() const { return m_fixedSampleRate; }
00071 
00073     bool getResampleOnLoad() const { return m_resampleOnLoad; }    
00074     
00076     bool getNormaliseAudio() const { return m_normaliseAudio; }
00077 
00078     enum BackgroundMode {
00079         BackgroundFromTheme,
00080         DarkBackground,
00081         LightBackground 
00082     };
00083     BackgroundMode getBackgroundMode() const { return m_backgroundMode; }
00084 
00085     enum TimeToTextMode {
00086         TimeToTextMs,
00087         TimeToTextUs,
00088         TimeToText24Frame,
00089         TimeToText25Frame,
00090         TimeToText30Frame,
00091         TimeToText50Frame,
00092         TimeToText60Frame
00093     };
00094     TimeToTextMode getTimeToTextMode() const { return m_timeToTextMode; }
00095 
00096     int getOctaveOfMiddleC() const {
00097         // weed out unsupported octaves
00098         return getOctaveOfMiddleCInSystem(getSystemWithMiddleCInOctave(m_octave));
00099     }
00100     int getOctaveOfLowestMIDINote() const {
00101         return getOctaveOfMiddleC() - 5;
00102     }
00103     
00104     bool getShowSplash() const { return m_showSplash; }
00105 
00106 public slots:
00107     virtual void setProperty(const PropertyName &, int);
00108 
00109     void setSpectrogramSmoothing(SpectrogramSmoothing smoothing);
00110     void setSpectrogramXSmoothing(SpectrogramXSmoothing smoothing);
00111     void setTuningFrequency(float freq);
00112     void setPropertyBoxLayout(PropertyBoxLayout layout);
00113     void setWindowType(WindowType type);
00114     void setResampleQuality(int quality);
00115     void setOmitTempsFromRecentFiles(bool omit);
00116     void setTemporaryDirectoryRoot(QString tempDirRoot);
00117     void setFixedSampleRate(int);
00118     void setResampleOnLoad(bool);
00119     void setNormaliseAudio(bool);
00120     void setBackgroundMode(BackgroundMode mode);
00121     void setTimeToTextMode(TimeToTextMode mode);
00122     void setOctaveOfMiddleC(int oct);
00123     void setViewFontSize(int size);
00124     void setShowSplash(bool);
00125 
00126 private:
00127     Preferences(); // may throw DirectoryCreationFailed
00128     virtual ~Preferences();
00129 
00130     static Preferences *m_instance;
00131 
00132     // We don't support arbitrary octaves in the gui, because we want
00133     // to be able to label what the octave system comes from. These
00134     // are the ones we support. (But we save and load as octave
00135     // numbers, so as not to make the prefs format really confusing)
00136     enum OctaveNumberingSystem {
00137         C0_Centre,
00138         C3_Logic,
00139         C4_ASA,
00140         C5_Sonar
00141     };
00142     static int getOctaveOfMiddleCInSystem(OctaveNumberingSystem s);
00143     static OctaveNumberingSystem getSystemWithMiddleCInOctave(int o);
00144 
00145     SpectrogramSmoothing m_spectrogramSmoothing;
00146     SpectrogramXSmoothing m_spectrogramXSmoothing;
00147     float m_tuningFrequency;
00148     PropertyBoxLayout m_propertyBoxLayout;
00149     WindowType m_windowType;
00150     int m_resampleQuality;
00151     bool m_omitRecentTemps;
00152     QString m_tempDirRoot;
00153     int m_fixedSampleRate;
00154     bool m_resampleOnLoad;
00155     bool m_normaliseAudio;
00156     int m_viewFontSize;
00157     BackgroundMode m_backgroundMode;
00158     TimeToTextMode m_timeToTextMode;
00159     int m_octave;
00160     bool m_showSplash;
00161 };
00162 
00163 #endif