What is the best way to program MIDI for Windows? - audio

I am looking to write a small program that receives input from an external device and then sends MIDI signals to any MIDI compatible software. What is the best way, from the MIDI perspective, to go about this? Are there any specific libraries I should look into?
Thanks.

PortMidi! http://portmedia.sourceforge.net/
It's easy to use, examples for Windows are provided.

MIDI protocol is quite simple, most MIDI APIs offer manipulation with MIDI events and their parameters. What differs is the way how MIDI devices are enumerated and opened.
Correct answer depends on your requirements.
What input from what external device will you use? Will it be another MIDI device, mouse, keyboard or something that will allow input event parsing? Or will you need some low level hardware access? This one may influence programming language selection, if Java, C++ or something different and therefore the library choice.
What programming language do you prefer? C++, Java... If you plan to develop in Java, you can do that with API that JDK provides.
Should the program be multiplatform? If it should and you plan to develop in C++, you should use multiplatform MIDI library, e.g http://portmedia.sourceforge.net/ mentioned by darasan or https://github.com/jdkoftinoff/jdksmidi Otherwise you could just stick with native platform API (Windows API, ALSA, not sure about Mac stuff).
Do you plan to use some specific MIDI device? Maybe there is library that provides easy access to some device functions via MIDI, that you would have to handle by yourself (e.g. some predefined SysEx data)
With more question details more libraries (or less libraries) can be recommended.

Related

Hardware communication with Python

Is it possible to write an API with Python so you can connect a physical ON and OFF switch via USB to a PC and when user presses the switch to ON or OFF, the python program detects it and send a signal to a web app and shows ON or OFF message on the website?
I am sorry if what I am asking its not clear enough!
Yes, it is possible. Reading USB devices can be done with Python. In linux USB device inputs can be found in some files(e.g. /dev/ttyUSB0). By reading those files you can get the information that you need. Putting here link that will be helpful
similar post
Firstly, you can't write an API to interact with hardware in python. You would have to use the pre-existing windows API(or the API provided by the Operating system that you are using) in order to interact with hardware in such a high-level language.
If you want to interact with hardware in python, and detect switch presses, releases etc, I would recommend you used a microcontroller such as a raspberry pi(for python) or an arduino(for C++). The respberry pi provides a very easy way to interact with hardware in python. If you still want to interact with a USB stick in python(but not acting as a switch) you can use the pyusb library.

webpage (django) <-> midi event (alsa) in Linux

I would like to create a web application that sends and receives ALSA MIDI messages on Linux. Only one web client is intended.
What kind of architecture / programs do I need for that?
I am familiar with django but can't find the missing link to ALSA (or any system with a gateway to ALSA on my Ubuntu machine). Also, I have the small program ttymidi (http://www.varal.org/ttymidi/), that sends messages from a serial port to ALSA.
You might be able to use Python's miscellaneous operating system interfaces, but web applications aren't often designed in this way. You may also have to worry about latency and buffering in your program.
The simplest way of doing what you want without any third-party library is to use pyALSA, which is the official python wrapper around the C ALSA library.
I recommend you dealing with the Sequencer API instead of the RawMIDI stuff, which is lower-level. Check out some of the test apps and the C API documentation, it will definetely help you to write your code.

Low level audio programming

I wonder; does audio software like Cubase and Audacity use PlaySound calls??
Where can I learn about low level audio programming? As far as I've found information on the web, MCI seems to be the lowest level audio API in Windows...
Thanks
Edit: I don't ask for information specific for Windows only.
There's several audio APIs to choose from. The oldest and most widely supported is the waveOut API - look for functions starting with waveOut in MSDN. A slightly newer one is DirectSound which is geared more towards games, but it's main feature over waveOut is positional 3D sound which professional audio software doesn't use (it was also supposed to have lower latency than waveOut, but that never really materialized). For low latency audio, there is ASIO. Professional audio apps support this API, but not all drivers do (it's a standard feature in professional sound cards, but not gaming or on-board hardware). ASIO can provide much lower latency than waveOut or DirectSound. Finally, there's the kernel streaming interface, which is the lowest-level audio interface still accessible from user-mode code. This is a direct pipe into Windows's internal mixer which combines output from all apps that are currently playing sound into the signal that gets sent to the sound card. It's scarcely documented though. There's a driver called ASIO4ALL (just google it) that provides ASIO support on soundcards without ASIO drivers by implementing the ASIO API on top of the kernel streaming interface.
I'm a little late to the game here, but I posted a Windows API history last week that might add a little more context. The choice of API really depends on your needs. If you want to avoid 3rd party libraries, it really only comes down to MME, XAudio2, and Core Audio (WASAPI).
A Brief History of Windows Audio APIs
Hope this helps!
Actually, if you are looking for more than Windows-only output support, then the best way to start is to review Phil Burk's PortAudio, available as of this writing at http://www.portaudio.com/ .
ASIO is a good quality interface, but it's proprietary and owned by Steinberg.
There are many lower-level interfaces to audio output than MCI in modern Windows. These include, at least, DirectSound, XAudio and WASAPI.
I recommend avoiding the Windows APIs as much as possible, and learning PortAudio instead.

voice encryption on fly in mobile phones

I want to encrypt voice calls on the fly. so which programming language should be preferred for symbian os. Are any API available for this purpose. which channel could be preferably used?
Have a look at http://www.developer.nokia.com/Community/Wiki/How_do_I_start_programming_for_Symbian_OS%3F about the different possibilities (programming language wise).
BTW: A good programmer can write faster code in Visual Basic than a bad programmer in Assembler.

Best cross-platform audio library for synchronizing audio playback

I'm writing a cross-platform program that involves scrolling a waveform along with uncompressed wav/aiff audio playback. Low latency and accuracy are pretty important. What is the best cross-platform audio library for audio playback when synchronizing to an external clock? By that I mean that I would like to be able to write the playback code so it sends events to a listener many times per second that includes the "hearing frame" at the moment of the notification.
That's all I need to do. No recording, no mixing, no 3d audio, nothing. Just playback with the best possible hearing frame notifications available.
Right now I am considering RTAudio and PortAudio, mostly the former since it uses ALSA.
The target platforms, in order of importance, are Mac OSX 10.5/6, Ubuntu 10.11, Windows XP/7.
C/C++ are both fine.
Thanks for your help!
The best performing cross platform library for this is jack. Properly configured, jack on Linux can outperform Windows asio easily (in terms of low latency processing without dropouts). But you cannot expect normal users to use jack (the demon should be started by the user before the app is started, and it can be a bit tricky to set up). If you are making an app specifically for pro-audio I would highly recommend looking in to jack.
Edit:
Portaudio is not as high-performance, but is much simpler for the user (no special configuration should be needed on their end, unlike jack). Most open source cross platform audio programs that I have used use portaudio (much moreso than openal), but unlike jack I have not used it personally. It is callback based, and looks pretty straightforward though.
OpenAL maybe an option for you.

Resources