コード例 #1
0
ファイル: Sequencer.cs プロジェクト: anyoddthing/XamarinSynth
        void RemoveNote(ref SeqCommand command)
        {
            var pos = command.IntValue1;

            if (pos >= 0)
            {
                _notePosition.RemoveAt(pos);
                _notes.RemoveAt(pos);
            }
        }
コード例 #2
0
 public void AddNote(int bar, float sub, float length, float frequency, float velocity)
 {
     _sequencer.AddCommand(
         SeqCommand.InsertNote(
             position:  RatioToSampleTime(bar, sub),
             length:    RatioToSampleTime(0, length),
             frequency: frequency,
             velocity:  velocity
             )
         );
 }
コード例 #3
0
ファイル: Sequencer.cs プロジェクト: anyoddthing/XamarinSynth
        void ScaleNotes(ref SeqCommand command)
        {
            var newLength = command.IntValue1;
            var factor    = ((double)newLength) / TotalLength;

            for (int i = 0; i < _notePosition.Count; i++)
            {
                _notePosition[i] = (int)Math.Round(factor * _notePosition[i]);

                var note = _notes[i];
                note.Length = (int)Math.Round(factor * note.Length);
                _notes[i]   = note;
            }
        }
コード例 #4
0
ファイル: Sequencer.cs プロジェクト: anyoddthing/XamarinSynth
        void ApplyCommand(ref SeqCommand command)
        {
            switch (command.Type)
            {
            case SeqCommand.CommandType.SetLength:
                TotalLength = command.IntValue1;
                break;

            case SeqCommand.CommandType.Start:
                IsRunning = true;
                break;

            case SeqCommand.CommandType.Stop:
                IsRunning = false;
                break;

            case SeqCommand.CommandType.SetLoop:
                IsLooping = true;
                break;

            case SeqCommand.CommandType.UnsetLoop:
                IsLooping = false;
                break;

            case SeqCommand.CommandType.InsertNote:
                InsertNote(ref command);
                break;

            case SeqCommand.CommandType.RemoveNote:
                RemoveNote(ref command);
                break;

            case SeqCommand.CommandType.ScaleNotes:
                ScaleNotes(ref command);
                break;

            default:
                break;
            }
        }
コード例 #5
0
ファイル: Sequencer.cs プロジェクト: anyoddthing/XamarinSynth
        void InsertNote(ref SeqCommand command)
        {
            var note = new SeqNote
            {
                Length    = command.IntValue2,
                Frequency = command.FloatValue1,
                Velocity  = command.FloatValue2,
            };

            var pos = _notePosition.BinarySearch(command.IntValue1);

            if (pos < 0)
            {
                _notePosition.Insert(~pos, command.IntValue1);
                _notes.Insert(~pos, note);
            }
            else
            {
                _notePosition[pos] = command.IntValue1;
                _notes[pos]        = note;
            }
        }
コード例 #6
0
 public void SetLength(int bars)
 {
     _sequencer.AddCommand(
         SeqCommand.SetLength((int)Math.Ceiling(BarsToSeconds(bars) * SampleRate))
         );
 }
コード例 #7
0
 void EnableLoop()
 {
     _sequencer.AddCommand(SeqCommand.SetLoop());
 }
コード例 #8
0
ファイル: Sequencer.cs プロジェクト: anyoddthing/XamarinSynth
 public void AddCommand(SeqCommand command)
 {
     _commands.Enqueue((command));
 }