/* Copyright (c) 2021 Alex Diener This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. Alex Diener alex@ludobloom.com */ #ifndef __MusicPattern_H__ #define __MusicPattern_H__ #ifdef __cplusplus extern "C" { #endif typedef struct MusicPattern MusicPattern; #define MusicPattern_superclass StemObject #include "audiosynth/Note.h" #include "gamemath/IntegerFraction.h" #include "stemobject/StemObject.h" #include typedef struct MusicPattern_note { NoteValue note; ifrac beat; float pressure; float holdDuration; uint32_t flags; unsigned int instrumentID; } MusicPattern_note; #define MUSICPATTERN_NOTE(note, beat, beatDivision, pressure, holdDuration, flags, instrumentID) ((MusicPattern_note) {note, {beat, beatDivision}, pressure, holdDuration, flags, instrumentID}) typedef struct MusicPattern_measure { unsigned int noteCount; MusicPattern_note * notes; } MusicPattern_measure; #define MusicPattern_measure_empty ((MusicPattern_measure) {0, NULL}) #define MusicPattern_ivars \ StemObject_ivars \ \ unsigned int meterSize; \ unsigned int meterBasicNote; \ unsigned int measureCount; \ MusicPattern_measure * measures; #define MusicPattern_vtable(self_type) \ StemObject_vtable(self_type) stemobject_declare(MusicPattern) MusicPattern * MusicPattern_create(unsigned int measureCount, unsigned int meterSize, unsigned int meterBasicNote); bool MusicPattern_init(MusicPattern * self, unsigned int measureCount, unsigned int meterSize, unsigned int meterBasicNote); void MusicPattern_dispose(MusicPattern * self); MusicPattern * MusicPattern_copy(MusicPattern * self); void MusicPattern_initCopy(MusicPattern * self, MusicPattern * original); void MusicPattern_addNote(MusicPattern * self, unsigned int measureIndex, MusicPattern_note note); void MusicPattern_addMeasure(MusicPattern * self, MusicPattern_measure measure); void MusicPattern_deleteMeasureAtIndex(MusicPattern * self, unsigned int measureIndex); #ifdef __cplusplus } #endif #endif