/// <summary> /// Adds an event object (section or event) into the song. /// </summary> /// <param name="syncTrackObject">Item to add.</param> /// <param name="autoUpdate">Automatically update all read-only arrays? /// If set to false, you must manually call the updateArrays() method, but is useful when adding multiple objects as it increases performance dramatically.</param> public void Add(Event eventObject, bool autoUpdate = true) { eventObject.song = this; SongObjectHelper.Insert(eventObject, _events); if (autoUpdate) { UpdateCache(); } }
/// <summary> /// Adds a synctrack object (bpm or time signature) into the song. /// </summary> /// <param name="syncTrackObject">Item to add.</param> /// <param name="autoUpdate">Automatically update all read-only arrays? /// If set to false, you must manually call the updateArrays() method, but is useful when adding multiple objects as it increases performance dramatically.</param> public void Add(SyncTrack syncTrackObject, bool autoUpdate = true) { syncTrackObject.song = this; SongObjectHelper.Insert(syncTrackObject, _syncTrack); if (autoUpdate) { UpdateCache(); } }
public uint GetCappedLengthForPos(uint pos) { uint newLength = length; if (pos > tick) { newLength = pos - tick; } else { newLength = 0; } Starpower nextSp = null; if (song != null && chart != null) { int arrayPos = SongObjectHelper.FindClosestPosition(this, chart.starPower); if (arrayPos == SongObjectHelper.NOTFOUND) { return(newLength); } while (arrayPos < chart.starPower.Count - 1 && chart.starPower[arrayPos].tick <= tick) { ++arrayPos; } if (chart.starPower[arrayPos].tick > tick) { nextSp = chart.starPower[arrayPos]; } if (nextSp != null) { // Cap sustain length if (nextSp.tick < tick) { newLength = 0; } else if (pos > nextSp.tick) { // Cap sustain newLength = nextSp.tick - tick; } } // else it's the only starpower or it's the last starpower } return(newLength); }
/// <summary> /// Adds a chart object (note, starpower and/or chart event) into the chart. /// </summary> /// <param name="chartObject">The item to add</param> /// <param name="update">Automatically update all read-only arrays? /// If set to false, you must manually call the updateArrays() method, but is useful when adding multiple objects as it increases performance dramatically.</param> public int Add(ChartObject chartObject, bool update = true) { chartObject.chart = this; chartObject.song = this._song; int pos = SongObjectHelper.Insert(chartObject, _chartObjects); if (update) { UpdateCache(); } return(pos); }
/// <summary> /// Converts a tick position into the time it will appear in the song. /// </summary> /// <param name="position">Tick position.</param> /// <param name="resolution">Ticks per beat, usually provided from the resolution song of a Song class.</param> /// <returns>Returns the time in seconds.</returns> public float TickToTime(uint position, float resolution) { int previousBPMPos = SongObjectHelper.FindClosestPosition(position, bpms); if (bpms[previousBPMPos].tick > position) { --previousBPMPos; } BPM prevBPM = bpms[previousBPMPos]; float time = prevBPM.assignedTime; time += (float)TickFunctions.DisToTime(prevBPM.tick, position, resolution, prevBPM.value / 1000.0f); return(time); }
/// <summary> /// Removes a chart object (note, starpower and/or chart event) from the chart. /// </summary> /// <param name="chartObject">Item to add.</param> /// <param name="update">Automatically update all read-only arrays? /// If set to false, you must manually call the updateArrays() method, but is useful when removing multiple objects as it increases performance dramatically.</param> /// <returns>Returns whether the removal was successful or not (item may not have been found if false).</returns> public bool Remove(ChartObject chartObject, bool update = true) { bool success = SongObjectHelper.Remove(chartObject, _chartObjects); if (success) { chartObject.chart = null; chartObject.song = null; } if (update) { UpdateCache(); } return(success); }
/// <summary> /// Removes an event object (section or event) from the song. /// </summary> /// <param name="autoUpdate">Automatically update all read-only arrays? /// If set to false, you must manually call the updateArrays() method, but is useful when removing multiple objects as it increases performance dramatically.</param> /// <returns>Returns whether the removal was successful or not (item may not have been found if false).</returns> public bool Remove(Event eventObject, bool autoUpdate = true) { bool success = false; success = SongObjectHelper.Remove(eventObject, _events); if (success) { eventObject.song = null; } if (autoUpdate) { UpdateCache(); } return(success); }
/// <summary> /// Removes a synctrack object (bpm or time signature) from the song. /// </summary> /// <param name="autoUpdate">Automatically update all read-only arrays? /// If set to false, you must manually call the updateArrays() method, but is useful when removing multiple objects as it increases performance dramatically.</param> /// <returns>Returns whether the removal was successful or not (item may not have been found if false).</returns> public bool Remove(SyncTrack syncTrackObject, bool autoUpdate = true) { bool success = false; if (syncTrackObject.tick > 0) { success = SongObjectHelper.Remove(syncTrackObject, _syncTrack); } if (success) { syncTrackObject.song = null; } if (autoUpdate) { UpdateCache(); } return(success); }
public Section GetPrevSection(uint position) { return(SongObjectHelper.GetPrevious(sections, position)); }
/// <summary> /// Finds the value of the first time signature that appears before the specified tick position. /// </summary> /// <param name="position">The tick position</param> /// <returns>Returns the value of the time signature that was found.</returns> public TimeSignature GetPrevTS(uint position) { return(SongObjectHelper.GetPrevious(timeSignatures, position)); }
/// <summary> /// Finds the value of the first bpm that appears before or on the specified tick position. /// </summary> /// <param name="position">The tick position</param> /// <returns>Returns the value of the bpm that was found.</returns> public BPM GetPrevBPM(uint position) { return(SongObjectHelper.GetPrevious(bpms, position)); }