MIDI File playback library for iOS - iphone

Is anyone aware of a library that can load a standard MIDI File and send the output to a MIDI interface? I've seen a number of libraries that play MIDI Files into an internal synthesizer, but none that will output to the MIDI interface.
Thanks in advance!

Start with MusicSequence from AudioToolbox.framework.
Create a MusicSequence then set the endpoint using MusicSequenceSetMIDIEndpoint.

Related

Flutter Desktop Windows Play Audio from Buffer

I need to play audio to an audio device that I would like to be able to select in the App. So far I've looked at just_audio but that doesn't seem to support "read from byte stream" for windows yet. I've also looked at libwinmedia but that is deprecated.
The audio is received as a ffi.Pointer to float samples or alternatively as 16bit Integer samples. I just need an API whether plugin or .h with ? .dll to select an audio device and send the audio buffer to it.
Does anyone know if I've missed this functionality in the dart packages or knows a simple library for c++ that I can use FFI to bind to that?
Thanks any help is appreciated.
I also looked at gstreamer but I don't want the user to have to install the gstreamer runtime.

is it possible to open and play midi file in iphone and change its tempo?

Is it possible to play .mid files directly via some API, or one have to convert the midi file to e.g. WAV first? if any one know please tell me i see others all the similar question but its nt wrkng well so if any one know than please tell. thanx.
You could use MusicPlayer APIs for playback.
To alter the tempo, see MusicPlayerSetPlayRateScalar.

“Hook” libMMS to FFmpeg for iPhone Streaming

These days, I was researching the software architechture for iPhone Streaming (Base on MMS protocol).
As we know, in order to playback MMS audio stream, we should call libMMS to read wma stream data from remote media server, and then call FFmpeg to decode the stream data from wma format into PCM data buffer, and finally, enqueue the PCM data buffer into iPhone’s audioqueue to generate real sound.
The introduction above just describe the working process of iPhone streaming. If we only need to implement this simple functionality, that is not difficult. Just follow the introduction above to call libMMS, FFMpeg and audioqueue step by step, we can achieve the streaming function. Actually, I have implemented the code last week.
But, what I need is not only a simple streaming function! I need a software architechture makes FFmpeg accessing libMMS just like accessing local filesystem!
Does anybody know how to hook the libMMS interfaces like mms_read/mms_seek onto FFmpeg filesystem interfaces like av_read_frame/av_seek_frame?
I think I have to answer my own question again this time……
After several weeks reseach and debuging, I got the truth finally.
Actually, we don’t need to “hook” libMMS onto FFMpeg. Why? Because the FFMpeg already has its native mms protocol process module “mms_protocol” (see in mms_protocol.c in FFMpeg).
All we need to do is just configuring the FFMpeg to enable the mms module like this (see in config.h in FFMpeg):
#define ENABLE_MMS_PROTOCOL 1
#define CONFIG_MMS_PROTOCOL 1
After this configuration, FFMpeg will add mms protocol into its protocol list. (Actually, the protocol list has already contained “local file system protocol”). As result, the FFMpeg could be able to treat the “mms://hostserver/abc” media file like local media file. Therefore, we can still open and read the mms media file using:
av_open_input_file();
av_read_frame();
like we did on local media file before!
By the way, in my ffmpeg version, there are still many bugs in libAVFormat module for proccessing mms protocol. It took one week for me to debug it, however, I think it will be much shorter for the guy as smart as you:-)

Programmatically playing MIDI with OpenAL and SF2

I can create a basic MIDI file from scratch verified using TiMidity++, and I know enough OpenAL to play a streamed source from a file.
I'm just wondering if it's possible to create a program in C to play MIDI files by reading in a SF2 and MIDI file and using OpenAL to play the sound. Do I need to use another library? I want to know beforehand because the SF2 format looks pretty complicated.
Core audio is where it's at!
If you are doing this on a mac, DLSMusicDevice does what you want.
if you are on iOS, you will need to do much 'by hand' but it is manageable (tedious, as well). If you go this route, look at the sample code 'mixer host'.
You need to use an CoreAudio. Create an AUGraph with a Sampler connected to an IOUnit. Look at header files AUComponent.h in the AudioUnit framework. Once you've got your audio graph setup you can play a note using the following function:
MusicDeviceMIDIEvent(sampler, status, note, velocity, 0);

Play midi file on the iPhone

Is it possible to play .mid files directly via some API, or one have to convert the midi file to e.g. AAC first?
(2 years later…) You can use MusicPlayer and MusicSequence APIs. Available in iOS 5.
There is no Apple API for this. You could write your own, which i think would depend on what you are hoping it is going sound like.
There is lots of available source code for reading midi files and there are a few open source synths for the iphone - or you could use openAl for triggering samples. It probably isn't going to sound like Garageband tho.
If you want it to sound as good as possible you will have to convert it first.