/// <summary> /// Indicate that the playback time has been reset to a different time and process events for a RhythmData. /// </summary> /// <param name="rhythmData">The rhyRhythmData object.</param> /// <param name="time">The new playback time.</param> public override void Reset(RhythmData rhythmData, float time) { if (offset > 0) { Process(rhythmData, time - offset, time); } }
/// <summary> /// Process events based on A RhythmData object and a time frame. /// </summary> /// <param name="rhythmData">The RhythmData to process.</param> /// <param name="start">The start of the time frame in seconds.</param> /// <param name="end">The end of the time frame in seconds.</param> public override void Process(RhythmData rhythmData, float start, float end) { foreach (var rhythmEvent in _events) { rhythmEvent.Value.Process(rhythmData, start + offset, end + offset); } }
private void CreateAsset() { string path = AssetDatabase.GetAssetPath(audioClip); path = Path.GetDirectoryName(path); string[] existingNames = AssetDatabase.FindAssets("t:RhythmData " + audioClip.name, new[] { path }); for (int i = 0; i < existingNames.Length; i++) { string assetPath = AssetDatabase.GUIDToAssetPath(existingNames[i]); existingNames[i] = Path.GetFileNameWithoutExtension(assetPath); } string name = ObjectNames.GetUniqueName(existingNames, audioClip.name); path = Path.Combine(path, name + ".asset"); RhythmData asset = analyzer.rhythmData; AssetDatabase.CreateAsset(asset, path); foreach (Track track in asset) { AssetDatabase.AddObjectToAsset(track, asset); } EditorUtility.SetDirty(asset); }
private void Initialize() { abort = false; isDone = false; initialized = false; progress = 0; lastFrame = 0; totalFrames = audioClip.samples / hopSize; channels = audioClip.channels; sampleRate = audioClip.frequency; initialLength *= sampleRate / hopSize; GetComponents(analyses); analyses.RemoveAll(a => !a.enabled); foreach (Analysis analysis in analyses) { analysis.Initialize(sampleRate, frameSize, hopSize); } rhythmData = RhythmData.Create(audioClip.name, analyses.Select(a => a.track)); StartAnalyze(); }
/// <summary> /// Create a RhythmData object with a name and tracks. /// </summary> /// <param name="name">The name of the RhythmData object.</param> /// <param name="tracks">A collection of Tracks to add to the RhythmData object.</param> /// <returns>A new RhythmData object.</returns> public static RhythmData Create(string name, IEnumerable <Track> tracks) { RhythmData data = CreateInstance <RhythmData>(); data._name = name; data._tracks = new List <Track>(tracks); return(data); }
/// <summary> /// Indicate that the playback time has been reset to a different time and process a RhythmData. /// </summary> /// <param name="rhythmData">The rhyRhythmData object.</param> /// <param name="time">The new playback time.</param> public abstract void Reset(RhythmData rhythmData, float time);
/// <summary> /// Process a RhythmData object with a certain time frame. /// </summary> /// <param name="rhythmData">The RhythmData object.</param> /// <param name="start">The start time in seconds.</param> /// <param name="end">The end time in seconds.</param> public abstract void Process(RhythmData rhythmData, float start, float end);