public Sequencer( Loader midiLoader ) { TimeSpanLogger.Begin(); PrepareTicksPerQuaterNote( midiLoader.headerInfo ); InitializeTrackSequences( midiLoader.trackInfos ); while ( !AllTracksHasEnded() ) { for ( int i = 0; i < trackSequences.Length; i++ ) { trackSequences[ i ].Process(); } } ConstructFakeTracks(); TimeSpanLogger.EndAndLog( "Sequencer done" ); }
public static void LogTo( Loader loader, string path ) { TimeSpanLogger.Begin(); StringBuilder sb = new StringBuilder(); LogStreamNameAndHeader( loader.headerInfo, path, sb ); for ( int i = 0; i < loader.trackInfos.Length; i++ ) { LogTrack( loader.trackInfos[i], sb ); } #if !UNITY_WEBPLAYER StreamWriter writer = File.CreateText( path ); string log = sb.ToString(); foreach ( char c in log ) { writer.Write( c ); } writer.Close(); #endif TimeSpanLogger.EndAndLog( "Logged parsing result to file" ); }
void ParseSequenceAndSave() { string inputPath = midiInputPath; AssertPathOK( inputPath ); string outputPath = assetOutputPath; AssertPathOK( outputPath ); MidiLoader.Loader loader = new MidiLoader.Loader( inputPath ); if ( useParsingLog ) { AssertPathOK( parsingLogOutputPath ); MidiLoader.LoaderLogger.LogTo( loader, parsingLogOutputPath ); } MidiFakeSequencer.Sequencer sequencer = new MidiFakeSequencer.Sequencer( loader ); if ( useSequencerLog ) { AssertPathOK( sequencerLogOutputPath ); MidiFakeSequencer.SequencerLogger.LogTo( sequencer, sequencerLogOutputPath ); } /* It's required for AssetDatabase to have paths relative to project directory */ outputPath = outputPath.Substring( outputPath.IndexOf( "Assets" ) ); CreateAndSaveAsset( sequencer.fakeTracks, outputPath ); }