Пример #1
0
 public static void Main(string[] args)
 {
     using (var settings = new Settings ()) {
         if (Environment.OSVersion.Platform == PlatformID.Unix)
             settings [ConfigurationKeys.AudioDriver].StringValue = "alsa";
         using (var syn = new Synth (settings)) {
             foreach (var arg in args)
                 if (Synth.IsSoundFont (arg))
                     syn.LoadSoundFont (arg, true);
             if (syn.FontCount == 0)
                 syn.LoadSoundFont ("/usr/share/sounds/sf2/FluidR3_GM.sf2", true);
             var files = args.Where (a => Synth.IsMidiFile (a));
             if (files.Any ()) {
                 foreach (var arg in files) {
                     using (var player = new Player (syn)) {
                         using (var adriver = new AudioDriver (syn.Settings, syn)) {
                             player.Add (arg);
                             player.Play ();
                             player.Join ();
                         }
                     }
                 }
             } else {
                 using (var adriver = new AudioDriver (syn.Settings, syn)) {
                     syn.NoteOn (0, 60, 100);
                     Thread.Sleep (5000);
                     syn.NoteOff (0, 60);
                 }
             }
         }
     }
 }
        public FluidsynthMidiReceiver(Context context)
        {
            #if MIDI_MANAGER
            access = new FluidsynthMidiAccess ();
            access.ConfigureSettings = (settings) => {
            #else
            var settings = new Settings ();
            #endif
            //settings [ConfigurationKeys.AudioDriver].StringValue = "opensles";

            //settings [ConfigurationKeys.SynthParallelRender].IntValue = 0;
            //settings [ConfigurationKeys.SynthThreadsafeApi].IntValue = 0;
            //settings [ConfigurationKeys.AudioPeriods].IntValue = 16;
            //settings [ConfigurationKeys.AudioPeriods].IntValue = 64;

            settings [ConfigurationKeys.AudioSampleFormat].StringValue = "16bits"; // float or 16bits

            var manager = context.GetSystemService (Context.AudioService).JavaCast<AudioManager> ();

            // Note that it is NOT audio sample rate but *synthesizing* sample rate.
            // So it is kind of wrong assumption that AudioManager.PropertyOutputSampleRate would give the best outcome...
            //var sr = double.Parse (manager.GetProperty (AudioManager.PropertyOutputSampleRate));
            //settings [ConfigurationKeys.SynthSampleRate].DoubleValue = sr;
            settings [ConfigurationKeys.SynthSampleRate].DoubleValue = 11025;

            var fpb = double.Parse (manager.GetProperty (AudioManager.PropertyOutputFramesPerBuffer));
            settings [ConfigurationKeys.AudioPeriodSize].IntValue = (int) fpb;
            #if MIDI_MANAGER
            };
            SynthAndroidExtensions.GetSoundFonts (access.SoundFonts, context, predefined_temp_path);
            output = access.OpenOutputAsync (access.Outputs.First ().Id).Result;
            #else
            syn = new Synth (settings);
            var sfs = new List<string> ();
            SynthAndroidExtensions.GetSoundFonts (sfs, context, predefined_temp_path);

            asset_stream_loader = new AndroidAssetStreamLoader (context.Assets);
            asset_sfloader = new SoundFontLoader (syn, asset_stream_loader);
            syn.AddSoundFontLoader (asset_sfloader);
            foreach (var sf in sfs)
                syn.LoadSoundFont (sf, false);

            adriver = new AudioDriver (syn.Settings, syn);
            #endif
        }
 public FileRenderer(Synth synth)
     : base(LibFluidsynth.Audio.new_fluid_file_renderer (synth.Handle), true)
 {
 }
 public AudioDriver(Settings settings, Synth synth)
     : base(LibFluidsynth.Audio.new_fluid_audio_driver (settings.Handle, synth.Handle), true)
 {
 }
Пример #5
0
 public Player(Synth synth)
     : base(LibFluidsynth.Midi.new_fluid_player (synth.Handle), true)
 {
 }
 public FileRenderer(Synth synth)
     : base(LibFluidsynth.new_fluid_file_renderer(synth.Handle))
 {
 }
Пример #7
0
 public AudioDriver(Settings settings, Synth synth)
     : base(LibFluidsynth.new_fluid_audio_driver(settings.Handle, synth.Handle))
 {
 }
Пример #8
0
 public Player(Synth synth)
     : base(LibFluidsynth.new_fluid_player(synth.Handle))
 {
 }