Exemplo n.º 1
0
        public void Flip_Should_Flip_From_Middle_When_Changing_Octave_Is_Not_Possible()
        {
            //Arrange
            MidiService target     = new MidiService();
            Stream      midiStream = File.Open($"{TestFilesPath}flip_from_middle_0_127.mid", FileMode.Open);
            const int   firstNote  = 127;
            const int   secondNote = 64;
            const int   thirdNote  = 63;
            const int   lastNote   = 0;

            //Act
            Stream flippedMidiStream = target.Flip(midiStream, 0);

            //Assert
            MidiSequence flippedMidi       = MidiSequence.Open(flippedMidiStream);
            int          firstFlippedNote  = flippedMidi.Tracks[2].Events.OfType <OnNoteVoiceMidiEvent>().First().Note;
            int          secondFlippedNote = flippedMidi.Tracks[2].Events.OfType <OnNoteVoiceMidiEvent>().ElementAt(1).Note;
            int          thirdFlippedNote  = flippedMidi.Tracks[2].Events.OfType <OnNoteVoiceMidiEvent>().ElementAt(2).Note;
            int          lastFlippedNote   = flippedMidi.Tracks[2].Events.OfType <OnNoteVoiceMidiEvent>().Last().Note;

            //Midi should be flipped around the middle
            Assert.AreEqual(firstNote, lastFlippedNote);
            Assert.AreEqual(secondNote, thirdFlippedNote);
            Assert.AreEqual(thirdNote, secondFlippedNote);
            Assert.AreEqual(firstFlippedNote, lastNote);
        }
Exemplo n.º 2
0
        public SettingsViewModel(
            IRuntimeConfigurationService configurationService,
            ILicenseService licenseService,
            ICommandManager commandManager, DataPersisterService dataPersisterService,
            GlobalFrontendService globalFrontendService, GlobalService globalService,
            IAdvancedMessageService advancedMessageService,
            AudioService audioService, MidiService midiService
            )
        {
            Argument.IsNotNull(() => configurationService);
            Argument.IsNotNull(() => commandManager);
            Argument.IsNotNull(() => licenseService);

            _configurationService   = configurationService;
            _commandManager         = commandManager;
            _globalService          = globalService;
            _advancedMessageService = advancedMessageService;

            ApplicationState = globalFrontendService.ApplicationState;

            OpenVstWorkerLogDirectory = new Command(OnOpenVstWorkerLogDirectoryExecute);
            OpenDataDirectory         = new Command(OnOpenDataDirectoryExecute);
            Title = "Settings";

            PresetDatabaseStatistics = dataPersisterService.GetStorageStatistics();

            TotalPresets = (from p in PresetDatabaseStatistics select p.PresetCount).Sum();
            TotalPresetsUncompressedSize = (from p in PresetDatabaseStatistics select p.PresetUncompressedSize).Sum();
            TotalPresetsCompressedSize   = (from p in PresetDatabaseStatistics select p.PresetCompressedSize).Sum();
            SavedSpace         = (from p in PresetDatabaseStatistics select p.SavedSpace).Sum();
            SavedSpacePercent  = (double)TotalPresetsCompressedSize / TotalPresetsUncompressedSize;
            AudioOutputDevices = audioService.GetOutputDevices();
            MidiInputDevices   = midiService.GetInputDevices();
        }
Exemplo n.º 3
0
        public void PatchPluginToMidiInput(RemoteVstPlugin plugin, MidiInputDevice device)
        {
            _midiTarget = plugin;
            var midiService = new MidiService();
            var midiInput   = midiService.GetMidiEndpoint(device);

            if (midiInput == null)
            {
                throw new Exception(
                          $"Unable to open MIDI device {device.Name} because the device  (currently) doesn't exists");
            }

            midiInput.NoteOn  += MidiInputOnNoteOn;
            midiInput.NoteOff += MidiInputOnNoteOff;
            midiInput.Open();

            _midiInputDevices.Add(midiInput);
        }
Exemplo n.º 4
0
        public void Flip_Should_Lower_Octave_When_Flipping_Above_127()
        {
            //Arrange
            MidiService target     = new MidiService();
            Stream      midiStream = File.Open($"{TestFilesPath}out_of_range_127.mid", FileMode.Open);
            const int   firstNote  = 127;
            const int   lastNote   = 115;

            //Act
            Stream flippedMidiStream = target.Flip(midiStream, 0);

            //Assert
            MidiSequence flippedMidi      = MidiSequence.Open(flippedMidiStream);
            int          firstFlippedNote = flippedMidi.Tracks[2].Events.OfType <OnNoteVoiceMidiEvent>().First().Note;
            int          lastFlippedNote  = flippedMidi.Tracks[2].Events.OfType <OnNoteVoiceMidiEvent>().Last().Note;

            //Midi should be flipped while also having been lowered by one octave
            Assert.AreEqual(firstNote, lastFlippedNote);
            Assert.AreEqual(firstFlippedNote, lastNote);
        }