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