MCPcopy Create free account
hub / github.com/DamRsn/NeuralNote / Notes

Class Notes

Lib/Model/Notes.h:20–263  ·  view source on GitHub ↗

* Class to extract note events from posteriorgrams (outputs of basic pitch cnn). */

Source from the content-addressed store, hash-verified

18 * Class to extract note events from posteriorgrams (outputs of basic pitch cnn).
19 */
20class Notes
21{
22public:
23 typedef struct Event {
24 double startTime;
25 double endTime;
26 int startFrame;
27 int endFrame;
28 int pitch; // pitch is not in Hz, but in "MIDI note number"
29 double amplitude;
30 std::vector<int> bends; // One vale of pitch bend per frame. Units is 1/3 of semitones.
31
32 bool operator==(const struct Event&) const;
33 } Event;
34
35 typedef struct ConvertParams {
36 /* Note segmentation (0.05 - 0.95, Split-Merge Notes) */
37 float onsetThreshold = 0.3;
38 /* Confidence threshold (0.05 to 0.95, More-Less notes) */
39 float frameThreshold = 0.5;
40 /* Minimum note length in number of frames */
41 int minNoteLengthFrames = 11;
42 bool inferOnsets = true;
43 float maxFrequency = -1; // in Hz, -1 means unset
44 float minFrequency = -1; // in Hz, -1 means unset
45 bool melodiaTrick = true;
46 PitchBendModes pitchBend = NoPitchBend;
47 int energyThreshold = 11;
48 } ConvertParams;
49
50 /**
51 * Create note events based on postegriorgram inputs
52 * @param inNotesPG Note posteriorgrams
53 * @param inOnsetsPG Onset posteriorgrams
54 * @param inContoursPG Contour posteriorgrams
55 * @param inParams input parameters
56 * @param inNewAudio True: first time calling this function with this audio (these inNotesPG, inOnsetsPG, inContoursPG).
57 * False if same audio as last time with updated parameters.
58 * @return
59 */
60 std::vector<Event> convert(const std::vector<std::vector<float>>& inNotesPG,
61 const std::vector<std::vector<float>>& inOnsetsPG,
62 const std::vector<std::vector<float>>& inContoursPG,
63 const ConvertParams& inParams,
64 bool inNewAudio);
65
66 /**
67 * Release any memory allocated by the class.
68 */
69 void clear();
70
71 /**
72 * Inplace sort of note events.
73 * @param inOutEvents
74 */
75 static inline void sortEvents(std::vector<Notes::Event>& inOutEvents)
76 {
77 std::sort(inOutEvents.begin(), inOutEvents.end(), [](const Event& a, const Event& b) {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected