annotate data/midi/rtmidi/RtError.h @ 1196:c7b9c902642f
spectrogram-minor-refactor
Fix threshold in spectrogram -- it wasn't working in the last release.
There is a new protocol for this. Formerly the threshold parameter had a
range from -50dB to 0 with the default at -50, and -50 treated internally
as "no threshold". However, there was a hardcoded, hidden internal threshold
for spectrogram colour mapping at -80dB with anything below this being rounded
to zero. Now the threshold parameter has range -81 to -1 with the default
at -80, -81 is treated internally as "no threshold", and there is no hidden
internal threshold. So the default behaviour is the same as before, an
effective -80dB threshold, but it is now possible to change this in both
directions. Sessions reloaded from prior versions may look slightly different
because, if the session says there should be no threshold, there will now
actually be no threshold instead of having the hidden internal one.
Still need to do something in the UI to make it apparent that the -81dB
setting removes the threshold entirely. This is at least no worse than the
previous, also obscured, magic -50dB setting.
author |
Chris Cannam |
date |
Mon, 01 Aug 2016 16:21:01 +0100 |
parents |
32d156c75df7 |
children |
|
rev |
line source |
Chris@559
|
1 /************************************************************************/
|
Chris@559
|
2 /*! \class RtError
|
Chris@559
|
3 \brief Exception handling class for RtAudio & RtMidi.
|
Chris@559
|
4
|
Chris@559
|
5 The RtError class is quite simple but it does allow errors to be
|
Chris@559
|
6 "caught" by RtError::Type. See the RtAudio and RtMidi
|
Chris@559
|
7 documentation to know which methods can throw an RtError.
|
Chris@559
|
8
|
Chris@559
|
9 */
|
Chris@559
|
10 /************************************************************************/
|
Chris@559
|
11
|
Chris@559
|
12 #ifndef RTERROR_H
|
Chris@559
|
13 #define RTERROR_H
|
Chris@559
|
14
|
Chris@559
|
15 #include <iostream>
|
Chris@559
|
16 #include <string>
|
Chris@559
|
17
|
Chris@559
|
18 class RtError
|
Chris@559
|
19 {
|
Chris@559
|
20 public:
|
Chris@559
|
21 //! Defined RtError types.
|
Chris@559
|
22 enum Type {
|
Chris@559
|
23 WARNING, /*!< A non-critical error. */
|
Chris@559
|
24 DEBUG_WARNING, /*!< A non-critical error which might be useful for debugging. */
|
Chris@559
|
25 UNSPECIFIED, /*!< The default, unspecified error type. */
|
Chris@559
|
26 NO_DEVICES_FOUND, /*!< No devices found on system. */
|
Chris@559
|
27 INVALID_DEVICE, /*!< An invalid device ID was specified. */
|
Chris@559
|
28 INVALID_STREAM, /*!< An invalid stream ID was specified. */
|
Chris@559
|
29 MEMORY_ERROR, /*!< An error occured during memory allocation. */
|
Chris@559
|
30 INVALID_PARAMETER, /*!< An invalid parameter was specified to a function. */
|
Chris@559
|
31 DRIVER_ERROR, /*!< A system driver error occured. */
|
Chris@559
|
32 SYSTEM_ERROR, /*!< A system error occured. */
|
Chris@559
|
33 THREAD_ERROR /*!< A thread error occured. */
|
Chris@559
|
34 };
|
Chris@559
|
35
|
Chris@559
|
36 protected:
|
Chris@559
|
37 std::string message_;
|
Chris@559
|
38 Type type_;
|
Chris@559
|
39
|
Chris@559
|
40 public:
|
Chris@559
|
41 //! The constructor.
|
Chris@559
|
42 RtError(const std::string& message, Type type = RtError::UNSPECIFIED) : message_(message), type_(type) {}
|
Chris@559
|
43
|
Chris@559
|
44 //! The destructor.
|
Chris@559
|
45 virtual ~RtError(void) {};
|
Chris@559
|
46
|
Chris@559
|
47 //! Prints thrown error message to stderr.
|
Chris@559
|
48 virtual void printMessage(void) { std::cerr << '\n' << message_ << "\n\n"; }
|
Chris@559
|
49
|
Chris@559
|
50 //! Returns the thrown error message type.
|
Chris@559
|
51 virtual const Type& getType(void) { return type_; }
|
Chris@559
|
52
|
Chris@559
|
53 //! Returns the thrown error message string.
|
Chris@559
|
54 virtual const std::string& getMessage(void) { return message_; }
|
Chris@559
|
55
|
Chris@559
|
56 //! Returns the thrown error message as a C string.
|
Chris@559
|
57 virtual const char *getMessageString(void) { return message_.c_str(); }
|
Chris@559
|
58 };
|
Chris@559
|
59
|
Chris@559
|
60 #endif
|