Beispiel #1
0
        private void PlayToFile(SoundFile soundFile, SoundTarget target)
        {
            logger.Info($"Writing playback of [green]{options.InputPath}[/] to [green]{options.OutputPath}[/]...");

            try
            {
                var transmitter = new MidiFileWriterTransmitter();
                using (var engine = new ImuseEngine(transmitter, target, options.ImuseOptions))
                {
                    // Clean up, even with Ctrl+C
                    ConsoleHelpers.SetupCancelHandler(engine, transmitter);

                    engine.RegisterSound(0, soundFile);
                    engine.StartSound(0);

                    transmitter.Start();

                    transmitter.Write(options.OutputPath);

                    ConsoleHelpers.TearDownCancelHandler();
                }
            }
            catch (ImuseException ex)
            {
                throw new ImuseSequencerException(ex.Message, ex);
            }
        }
Beispiel #2
0
        private void PlayToDevice(SoundFile soundFile, SoundTarget target)
        {
            logger.Info($"Playing [green]{options.InputPath}[/]...");
            var uiHandler = new UIHandler();

            options.DeviceSelector = OutputHelpers.Instance.DetermineDeviceSelector(options.DeviceSelector, target);

            try
            {
                using (var transmitter = OutputHelpers.Instance.CreateTransmitter(options.DeviceSelector, options.Latency))
                {
                    using (var engine = new ImuseEngine(transmitter, target, options.ImuseOptions))
                    {
                        // Clean up, even with Ctrl+C
                        ConsoleHelpers.SetupCancelHandler(engine, transmitter);

                        logger.Info($"Target device: [green]{target.GetDisplayName()}[/]");
                        logger.Info($"Outputting to: [green]{transmitter.OutputName}[/]");
                        logger.Info($"iMUSE version: [green]{soundFile.ImuseVersion.GetDisplayName()}[/]");
                        logger.Info("");

                        engine.RegisterSound(0, soundFile);
                        engine.StartSound(0);

                        logger.Info("");

                        BuildCommands(engine, uiHandler);
                        uiHandler.OutputMenu();

                        transmitter.Start();

                        uiHandler.Run();

                        ConsoleHelpers.TearDownCancelHandler();
                    }
                }
            }
            catch (ImuseException ex)
            {
                throw new ImuseSequencerException(ex.Message, ex);
            }
        }