Skip to content

Commit

Permalink
add poc ; add testing data
Browse files Browse the repository at this point in the history
  • Loading branch information
Kippy committed Oct 19, 2022
1 parent 3aecddf commit 96d5081
Show file tree
Hide file tree
Showing 84 changed files with 553 additions and 0 deletions.
16 changes: 16 additions & 0 deletions MidiMetronome.asmdef
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "MidiMetronome",
"rootNamespace": "",
"references": [],
"includePlatforms": [],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": true,
"precompiledReferences": [
"Melanchall.DryWetMidi.dll"
],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
}
7 changes: 7 additions & 0 deletions MidiMetronome.asmdef.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions Utility.Tests.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

70 changes: 70 additions & 0 deletions Utility.Tests/GeneralTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
using MidiMetronome;
using NUnit.Framework;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using UnityEditor;
using UnityEngine;

public class GeneralTests
{
readonly string[] MidiTestFiles = new string[]
{
"MIDI_sample",
"darude-sandstorm",
"dr.dre-still",
"Under-The-Sea-(From-'The-Little-Mermaid')"
};

[Test]
public void Dev()
{
var assets = AssetDatabase.FindAssets(nameof(GeneralTests))
.Select(guid => AssetDatabase.GUIDToAssetPath(guid))
.Select(path => AssetDatabase.LoadAssetAtPath<MonoScript>(path))
.Distinct();

var script = assets.FirstOrDefault();

if (script == null)
throw new Exception($"Can't locate the script in the project!");

var path = AssetDatabase.GetAssetPath(script);
var root = Path.GetDirectoryName(path);
var sampleDir = $@"{root}\Samples";

var midiFiles = Directory.GetFiles(sampleDir, "*.mid")
.Select(x => new { name = Path.GetFileName(x), rawMidi = File.ReadAllBytes(x) });

foreach (var x in midiFiles)
TestMidi(x.rawMidi, x.name);
}
void TestMidi(byte[] rawMidi, string name)
{

TickInfo[] ticks = null;

try
{
ticks = MetronomeUtility.GenerateBeats(rawMidi);
}
catch (Exception e)
{
Debug.LogError(name);
Debug.LogException(e);
}

if (ticks == null)
return;

Debug.Log($"{name}");

foreach (var x in ticks)
{
Debug.Log($"[{x.BPM:F0}] {x.Time:0.###}s");
}

Debug.Log("======================");
}
}
11 changes: 11 additions & 0 deletions Utility.Tests/GeneralTests.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions Utility.Tests/MidiMetronome.Tests.asmdef
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"name": "MidiMetronome.Tests",
"rootNamespace": "",
"references": [
"MidiMetronome"
],
"includePlatforms": [
"Editor"
],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": true,
"precompiledReferences": [
"Melanchall.DryWetMidi.dll",
"nunit.framework.dll"
],
"autoReferenced": false,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
}
7 changes: 7 additions & 0 deletions Utility.Tests/MidiMetronome.Tests.asmdef.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions Utility.Tests/Samples.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added Utility.Tests/Samples/climb.mid
Binary file not shown.
7 changes: 7 additions & 0 deletions Utility.Tests/Samples/climb.mid.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions Utility.Tests/~Samples.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added Utility.Tests/~Samples/Ahfat01.MID
Binary file not shown.
7 changes: 7 additions & 0 deletions Utility.Tests/~Samples/Ahfat01.MID.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added Utility.Tests/~Samples/Ahfat02.MID
Binary file not shown.
7 changes: 7 additions & 0 deletions Utility.Tests/~Samples/Ahfat02.MID.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added Utility.Tests/~Samples/Ahfat03.MID
Binary file not shown.
7 changes: 7 additions & 0 deletions Utility.Tests/~Samples/Ahfat03.MID.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added Utility.Tests/~Samples/Ahfat04.MID
Binary file not shown.
7 changes: 7 additions & 0 deletions Utility.Tests/~Samples/Ahfat04.MID.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.
7 changes: 7 additions & 0 deletions Utility.Tests/~Samples/Carter_Family_Wildwood_Flower.mid.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added Utility.Tests/~Samples/Cherubichymn.mid
Binary file not shown.
7 changes: 7 additions & 0 deletions Utility.Tests/~Samples/Cherubichymn.mid.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added Utility.Tests/~Samples/Don't be cruel L.mid
Binary file not shown.
7 changes: 7 additions & 0 deletions Utility.Tests/~Samples/Don't be cruel L.mid.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added Utility.Tests/~Samples/Dr Dre - Still Dre (1).mid
Binary file not shown.
7 changes: 7 additions & 0 deletions Utility.Tests/~Samples/Dr Dre - Still Dre (1).mid.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.
7 changes: 7 additions & 0 deletions Utility.Tests/~Samples/Eine-Kleine-Nachtmusik1.mid.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added Utility.Tests/~Samples/EvilWays3.mid
Binary file not shown.
7 changes: 7 additions & 0 deletions Utility.Tests/~Samples/EvilWays3.mid.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added Utility.Tests/~Samples/FZero - Ending.mid
Binary file not shown.
7 changes: 7 additions & 0 deletions Utility.Tests/~Samples/FZero - Ending.mid.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added Utility.Tests/~Samples/Give-Me-All-Your-Love.mid
Binary file not shown.
7 changes: 7 additions & 0 deletions Utility.Tests/~Samples/Give-Me-All-Your-Love.mid.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added Utility.Tests/~Samples/K074.MID
Binary file not shown.
7 changes: 7 additions & 0 deletions Utility.Tests/~Samples/K074.MID.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added Utility.Tests/~Samples/MIDI_sample.mid
Binary file not shown.
7 changes: 7 additions & 0 deletions Utility.Tests/~Samples/MIDI_sample.mid.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added Utility.Tests/~Samples/The-Eyes-Of-Jenny.mid
Binary file not shown.
7 changes: 7 additions & 0 deletions Utility.Tests/~Samples/The-Eyes-Of-Jenny.mid.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.
7 changes: 7 additions & 0 deletions Utility.Tests/~Samples/Tiesto - Theme From Norefjell.mid.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added Utility.Tests/~Samples/WalkDon'tRun.mid
Binary file not shown.
7 changes: 7 additions & 0 deletions Utility.Tests/~Samples/WalkDon'tRun.mid.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added Utility.Tests/~Samples/Wayout.mid
Binary file not shown.
7 changes: 7 additions & 0 deletions Utility.Tests/~Samples/Wayout.mid.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added Utility.Tests/~Samples/WoO055 Prelude.mid
Binary file not shown.
7 changes: 7 additions & 0 deletions Utility.Tests/~Samples/WoO055 Prelude.mid.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added Utility.Tests/~Samples/ab.mid
Binary file not shown.
7 changes: 7 additions & 0 deletions Utility.Tests/~Samples/ab.mid.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added Utility.Tests/~Samples/bilyjean.mid
Binary file not shown.
7 changes: 7 additions & 0 deletions Utility.Tests/~Samples/bilyjean.mid.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added Utility.Tests/~Samples/blitzkrieg.mid
Binary file not shown.
Loading

0 comments on commit 96d5081

Please sign in to comment.