annotate data/model/NoteData.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 cc27f35aa75c
children 48e9f538e6e9
rev   line source
Chris@852 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
Chris@852 2
Chris@852 3 /*
Chris@852 4 Sonic Visualiser
Chris@852 5 An audio file viewer and annotation editor.
Chris@852 6 Centre for Digital Music, Queen Mary, University of London.
Chris@852 7
Chris@852 8 This program is free software; you can redistribute it and/or
Chris@852 9 modify it under the terms of the GNU General Public License as
Chris@852 10 published by the Free Software Foundation; either version 2 of the
Chris@852 11 License, or (at your option) any later version. See the file
Chris@852 12 COPYING included with this distribution for more information.
Chris@852 13 */
Chris@852 14
Chris@852 15 #ifndef NOTE_DATA_H
Chris@852 16 #define NOTE_DATA_H
Chris@852 17
Chris@852 18 #include <vector>
Chris@852 19
Chris@865 20 #include "base/Pitch.h"
Chris@865 21
Chris@852 22 struct NoteData
Chris@852 23 {
Chris@1038 24 NoteData(sv_frame_t _start, sv_frame_t _dur, int _mp, int _vel) :
Chris@852 25 start(_start), duration(_dur), midiPitch(_mp), frequency(0),
Chris@996 26 isMidiPitchQuantized(true), velocity(_vel), channel(0) { };
Chris@852 27
Chris@1038 28 sv_frame_t start; // audio sample frame
Chris@1038 29 sv_frame_t duration; // in audio sample frames
Chris@996 30 int midiPitch; // 0-127
Chris@865 31 float frequency; // Hz, to be used if isMidiPitchQuantized false
Chris@852 32 bool isMidiPitchQuantized;
Chris@996 33 int velocity; // MIDI-style 0-127
Chris@996 34 int channel; // MIDI 0-15
Chris@865 35
Chris@865 36 float getFrequency() const {
Chris@865 37 if (isMidiPitchQuantized) {
Chris@1038 38 return float(Pitch::getFrequencyForPitch(midiPitch));
Chris@865 39 } else {
Chris@865 40 return frequency;
Chris@865 41 }
Chris@865 42 }
Chris@852 43 };
Chris@852 44
Chris@852 45 typedef std::vector<NoteData> NoteList;
Chris@852 46
Chris@852 47 class NoteExportable
Chris@852 48 {
Chris@852 49 public:
Chris@852 50 virtual NoteList getNotes() const = 0;
Chris@1038 51 virtual NoteList getNotesWithin(sv_frame_t startFrame, sv_frame_t endFrame) const = 0;
Chris@852 52 };
Chris@852 53
Chris@852 54 #endif