Esempio n. 1
0
        public static void LogTo( Sequencer sequencer, string path )
        {
            TimeSpanLogger.Begin();
            StringBuilder sb = new StringBuilder();

            for ( int i = 0; i < sequencer.fakeTracks.Length; i++ ) {
                sb.AppendLine( "Track " + sequencer.fakeTracks[ i ].name + ":" );
                for ( int j = 0; j < sequencer.fakeTracks[ i ].noteOns.Length; j++ ) {
                    Sequencer.NoteOn on = sequencer.fakeTracks[ i ].noteOns[ j ];
                    sb.AppendLine( " realtime: " + on.realtime.ToString( "#00000.000" )
                                  #if SEQUENCE_NOTES
                                  + " " + on.note
                                  #endif
                                  );
                }
            }

            #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 sequencer result to file" );
        }
Esempio n. 2
0
        public TrackSequence( Sequencer fakeSequencer, TrackInfo trackInfo )
        {
            sequencer = fakeSequencer;
            info = trackInfo;

            nextEventIndex = 0;
            trackEnded = false;
            remainingDeltas = info.events[ 0 ].deltas;
            sumsOfDeltas = remainingDeltas;
            noteOns = new List<Sequencer.NoteOn>();
        }
    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 );
    }