Skip to content

Instantly share code, notes, and snippets.

@mes51
Last active September 27, 2018 16:56
Show Gist options
  • Save mes51/8784aea945eba8200560724303bfee1b to your computer and use it in GitHub Desktop.
Save mes51/8784aea945eba8200560724303bfee1b to your computer and use it in GitHub Desktop.
Intervallo JsonLoader Format
class ExportSample
{
public static void Export(string filePath, double framePeriod, ScaleInterpolationType interpolationType, double[] scales)
{
var data = new ScaleData
{
FramePeriod = framePeriod,
InterpolationType = interpolationType,
Scales = scales
};
using (var fs = new FileStream(filePath, FileMode.Create)
{
var serializer = new DataContractJsonSerializer(typeof(ScaleData));
serializer.WriteObject(fs, data);
}
}
}
/// <summary>
/// 音階データ
/// </summary>
public class ScaleData
{
/// <summary>
/// 各フレームの長さ(ms)
/// </summary>
public double FramePeriod { get; set; }
/// <summary>
/// 補間タイプ
/// </summary>
public ScaleInterpolationType InterpolationType { get; set; }
/// <summary>
/// フレームごとの音階(MIDIノート番号)
/// </summary>
public double[] Scales { get; set; }
}
/// <summary>
/// 補間モード
/// </summary>
public enum ScaleInterpolationType
{
/// <summary>
/// 線形補間
/// </summary>
Linear,
/// <summary>
/// CatmullRom補間
/// </summary>
CatmullRom
}
// DataContractJsonSerializerで書き出されたものを前提とします
{
"FramePeriod": 2.0,
"InterpolationType": 1,
"Scales": [
0.0,
60.0,
68.0,
60.0,
70.0,
67.0,
69.0,
60.0
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment