svcore  1.9
NoteData.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     
00008     This program is free software; you can redistribute it and/or
00009     modify it under the terms of the GNU General Public License as
00010     published by the Free Software Foundation; either version 2 of the
00011     License, or (at your option) any later version.  See the file
00012     COPYING included with this distribution for more information.
00013 */
00014 
00015 #ifndef NOTE_DATA_H
00016 #define NOTE_DATA_H
00017 
00018 #include <vector>
00019 
00020 #include "base/Pitch.h"
00021 
00022 struct NoteData
00023 {
00024     NoteData(int _start, int _dur, int _mp, int _vel) :
00025         start(_start), duration(_dur), midiPitch(_mp), frequency(0),
00026         isMidiPitchQuantized(true), velocity(_vel) { };
00027             
00028     int start;     // audio sample frame
00029     int duration;  // in audio sample frames
00030     int midiPitch; // 0-127
00031     float frequency; // Hz, to be used if isMidiPitchQuantized false
00032     bool isMidiPitchQuantized;
00033     int velocity;  // MIDI-style 0-127
00034 
00035     float getFrequency() const {
00036         if (isMidiPitchQuantized) {
00037             return Pitch::getFrequencyForPitch(midiPitch);
00038         } else {
00039             return frequency;
00040         }
00041     }
00042 };
00043 
00044 typedef std::vector<NoteData> NoteList;
00045 
00046 class NoteExportable
00047 {
00048 public:
00049     virtual NoteList getNotes() const = 0;
00050     virtual NoteList getNotesWithin(int startFrame, int endFrame) const = 0;
00051 };
00052 
00053 #endif