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 SV_NOTE_DATA_H
16 #define SV_NOTE_DATA_H
17 
18 #include <vector>
19 
20 #include "Pitch.h"
21 
25 struct NoteData
26 {
27  NoteData(sv_frame_t _start, sv_frame_t _dur, int _mp, int _vel) :
28  start(_start), duration(_dur), midiPitch(_mp), frequency(0),
29  isMidiPitchQuantized(true), velocity(_vel), channel(0) { };
30 
31  sv_frame_t start; // audio sample frame
32  sv_frame_t duration; // in audio sample frames
33  int midiPitch; // 0-127
34  float frequency; // Hz, to be used if isMidiPitchQuantized false
36  int velocity; // MIDI-style 0-127
37  int channel; // MIDI 0-15
38 
39  float getFrequency() const {
40  if (isMidiPitchQuantized) {
41  return float(Pitch::getFrequencyForPitch(midiPitch));
42  } else {
43  return frequency;
44  }
45  }
46 };
47 
48 typedef std::vector<NoteData> NoteList;
49 
50 #endif
static double getFrequencyForPitch(int midiPitch, double centsOffset=0, double concertA=0.0)
Return the frequency at the given MIDI pitch plus centsOffset cents (1/100ths of a semitone)...
Definition: Pitch.cpp:23
float frequency
Definition: NoteData.h:34
Note record used when constructing synthetic events for sonification.
Definition: NoteData.h:25
sv_frame_t start
Definition: NoteData.h:29
int64_t sv_frame_t
Frame index, the unit of our time axis.
Definition: BaseTypes.h:31
float getFrequency() const
Definition: NoteData.h:39
bool isMidiPitchQuantized
Definition: NoteData.h:35
sv_frame_t duration
Definition: NoteData.h:32
int channel
Definition: NoteData.h:37
NoteData(sv_frame_t _start, sv_frame_t _dur, int _mp, int _vel)
Definition: NoteData.h:27
std::vector< NoteData > NoteList
Definition: NoteData.h:48
int velocity
Definition: NoteData.h:36
int midiPitch
Definition: NoteData.h:33