private string mName = null; //!< The name of the Song. /*************************************************************************//** * @} * @defgroup SongConstruct Constructors * @ingroup DocSong * Constructors to create a new Song instance. * @{ *****************************************************************************/ /** * @brief The default constructor. * @return A new empty Song. * Initializes the @link Song::mNotes list of notes@endlink and sets the @link Song::mBPM BPM@endlink to 120, * the @link Music::TimeSignature time signature@endlink to @link Music::TIME_SIGNATURE_4_4 4/4@endlink * and the @link Song::mName name of the Song@endlink to "Untitled". */ public Song() { // Set the member variables. mNotes = new List <Music.CombinedNote>(); mTimeSignature = Music.TIME_SIGNATURE_4_4(); mBPM = 120; mName = "Untitled"; }
/** * @brief Sets the @link Music::TimeSignature time signature@endlink of the Song. * @param[in] aTimeSignature The @link Music::TimeSignature time signature@endlink of the Song. */ public void SetTimeSignature(Music.TimeSignature aTimeSignature) { mTimeSignature.BeatsPerMeasure = aTimeSignature.BeatsPerMeasure; mTimeSignature.BaseBeat = aTimeSignature.BaseBeat; }
/*************************************************************************//** * @} * @defgroup SongStatFunc Static Functions * @ingroup DocSong * Functions related to @link Song Songs@endlink that can be used without having to have an actual instance of a Song. * @{ *****************************************************************************/ /** * @brief Gets the number of waveform samples required to accurately represent the @link Music::NOTE_LENGTH_BASE length of a note@endlink for a given @link DefBPM BPM@endlink and @link Music::TimeSignature time signature@endlink. * @param[in] aBPM The @link DefBPM BPM@endlink that should be accounted for. * @param[in] aSampleRate The sample rate of the note. Might need to remove since most likely everything's going to have a 44\.1KHz sample rate. * @param[in] aNoteLength The @link Music::NOTE_LENGTH_BASE note length@endlink that's being converted into a number of waveform samples. * @param[in] aTimeSignature The @link Music::TimeSignature time signature@endlink that should be accounted for. * @return The number of waveform samples that represents the given @link Music::NOTE_LENGTH_BASE note length@endlink at the given @link DefBPM BPM@endlink and @link Music::TimeSignature time signature@endlink. * */ public static int GetNoteLengthInSamples(int aBPM, int aSampleRate, Music.NoteLength aNoteLength, Music.TimeSignature aTimeSignature) { // Initialize variables for calculating the note length. float beatsPerSecond = (float)aBPM / 60f; // Since the audio data is split into two channels with even indices for the data // in the left channel and odd indices for the data in the right channel, the // actual conversion for number of samples per second is 2 * sample rate. float numSamplesPerBeat = 2f * (1f / beatsPerSecond) * (float)aSampleRate; // Calculate the length for various time signatures by relating the base beat to // a quarter note. float numQuarterNotesPerBeat = 1f; // Right now, only provide support for base beats of 4 and 8. switch (aTimeSignature.BaseBeat) { case Music.NOTE_LENGTH_BASE.E: numQuarterNotesPerBeat /= 2f; break; default: break; } // Calculate the note length in samples. return((int)(numSamplesPerBeat * (Music.GetNoteLengthRelativeToQuarterNote(aNoteLength) * numQuarterNotesPerBeat))); }