本文整理汇总了C#中Sequence.Save方法的典型用法代码示例。如果您正苦于以下问题:C# Sequence.Save方法的具体用法?C# Sequence.Save怎么用?C# Sequence.Save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sequence
的用法示例。
在下文中一共展示了Sequence.Save方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
static void Main(string[] args)
{
var sequence = new Sequence();
//TestPianoTrack(sequence);
//TestDrumTrack(sequence);
//TestGunshotTrack(sequence);
var drumBot = new DrumBotV1(sequence);
var chordBot = new ChordBotV1(sequence);
sequence.Save("C:\\al-dev\\alalbers.Midi\\MidiFiles\\" + Guid.NewGuid() + ".mid");
Console.WriteLine("MIDI file generated");
Console.ReadLine();
}
示例2: Save
public static void Save(List<List<Event>> allEvents, string path)
{
Sequence sequence = new Sequence();
Dictionary<int, Track> tracks = new Dictionary<int, Track>();
for (int trackIndex = 0; trackIndex < allEvents.Count; trackIndex++)
{
Track track = new Track();
sequence.Add(track);
List<Event> trackEvents = allEvents[trackIndex];
foreach (var midiEvent in trackEvents.Select(trackEvent => new { Tick = trackEvent.Tick, MidiMessage = Convert(trackEvent, track) }))
{
track.Insert(midiEvent.Tick, midiEvent.MidiMessage);
}
}
sequence.Save(path);
}
示例3: Main
//.........这里部分代码省略.........
{
NoteOff(tick, ti);
}
}
else
{
//if (ce.Volume != -1 && ce.Volume < 32) continue;
if (ti.LastPitch != -1)
{
NoteOff(tick, ti);
}
//p = ProgramChange(ti.Track, tick, p, ce);
var delay = 0;
if (ce.Command == 19)
{
if (208 <= ce.Data && ce.Data <= 214) // HACK: 214 is a guess at the top range of SD commands
{
delay = ce.Data - 208;
Debug.Assert(delay >= 0);
}
}
NoteOn(tick + delay, ti, ce);
}
}
tick += speed;
if (breakPattern)
{
break;
}
}
}
foreach (var pair in tracks)
{
if (pair.Value.LastPitch != -1)
{
NoteOff(tick, pair.Value);
}
}
foreach (MidiEvent m in drums.Iterator().Take(5))
{
if (m.MidiMessage is ChannelMessage)
{
ChannelMessage cm = (ChannelMessage)m.MidiMessage;
Console.Out.WriteLine("{0} {1}", m.AbsoluteTicks, cm.Command);
}
}
s.Save(Path.ChangeExtension(filename, ".mid"));
/*
var tick = 0;
var speed = 3;
var lastNote = -1;
var p = -1;
foreach (var ce in c1)
{
if (ce == null || ce.Note == -1 || ce.Note == 0xFF)
{
tick += speed;
Console.Out.WriteLine("skip");
continue;
}
else if (ce.Note == 0xFE) //off
{
lastNote = NoteOff(t, tick, lastNote);
}
else
{
if (lastNote != -1)
{
lastNote = NoteOff(t, tick, lastNote);
}
p = ProgramChange(t, tick, p, ce);
var delay = 0;
if (ce.Command == 19)
{
if (208 <= ce.Data && ce.Data <= 214) // HACK: 214 is a guess at the top range of SD commands
{
delay = ce.Data - 208;
Debug.Assert(delay >= 0);
}
}
lastNote = NoteOn(t, tick + delay, ce.Note);
}
tick += speed;
}
lastNote = NoteOff(t, tick, lastNote);
*
* */
}