I'm looking for a cross-platform C or C++ MIDI library. Just to send/receive MIDI note events, control codes and timing, not to generate sound.
The main target is iOS/iPad so it has to support CoreMIDI on iOS, which I know is fairly recent. I can use CoreMidi directly but if there's something lightweight out there it would be nice to use something portable so I could easily port the project to PC's.
Failing that, please mention if there's a good, lightweight one that's open source it might be easier for me to add CoreMIDI support than to roll my own.
Clarification: I'm looking for something similar to MidiIO or PortMIDI that has good iOS support.
You might want to take a look at RtMidi.
It provides a cross-platform API for realtime MIDI input/output, and makes use of the native API's for each platform (winmm, ALSA, CoreMidi).
I haven't used it with CoreAudio/CoreMidi, but it's worked flawlessly for me on Windows and Linux.
I don't know MIDI thing in iOS dev. To my understanding, sending/receiving MIDI note events to/from MIDI devices should be a pure OS API problem. And parsing/generating MIDI messages is about MIDI spec. I suppose neither leads to a need of a library.
Related
I need to implement an application on Linux that drives a USB connected device (a medical instrument). The application will be written in C++ (2011 standard).
The current application is written for Windows 10 in C# and uses the standard Winusb driver enumerated for the device. I have a complete protocol specification for the commands and the events/interrupts coming back. Unfortunately, I'm not sure how I can pass these to the USB layer in Linux. If it was a simple serial device, there would be no problem but I'm guessing the command responses and the interrupt events are multiplexed by the driver using the functionality in the Winusb driver.
Where's the best place to start in terms of documentation? Alternatively, is there a Linux library (or driver) that provides more or less the same functionality as winusb for Linux?
Any help appreciated. Thanks
Alternatively, is there a Linux library (or driver) that provides more or less the same functionality as winusb for Linux?
One way is using directly the generic kernel API for USB (see the Asynchronous I/O parts to get the interrupts):
https://www.kernel.org/doc/html/v4.15/driver-api/usb/usb.html
This is the strict Linux equivalent of WinUSB.
The potentially less hard way is using libusb, which also get you cross-platform features.
(I am assuming your device is recognized correctly by the kernel, and doesn't need a custom driver)
Is there a Linux library (or driver) that provides more or less the same functionality as winusb for Linux?
Yes. libusb is a popular USB abstraction library that supports Linux, macOS, and Windows. I also wrote a similar library called libusbp with a different set of features that were more useful for my applications. These are C libraries so it will take some work to interoperate with them from C#, but once you do that, you can probably use the same code on either Windows or Linux (so you wouldn't have to maintain your code for calling WinUSB).
I have writen an objective-c POS that needs to interact with many ethernet devices like barcode scanner, fuel pump, cash drawer, etc. I know i'll probably have to write drivers in c++ for each device. The problem is I have no idea of how to write ethernet devices drivers. Is there anybody who can help me?
Btw, I haven't seen any code sample for ethernet drivers on the Apple dev site.
Thanks in advance!
If the platform your working with is running iOS or MacOS, then it already has an Ethernet driver and a TCP/IP stack. What you probably need to write are modules/classes that communicate with the various devices using a socket API. These modules/classes are written at the application level, and are not OS device drivers.
To use sockets on iOS/MacOS, you can work with either the CFNetwork framework, or more directly with BSD sockets. There is lots of literature and examples on socket programming. There is not as much litterature on CFNetwork, but CFNetwork has the advantage of being easier to integrate with your app's run loops.
Check out this answer that lists resources for learning sockets network programming.
A third option would be to use the Boost.Asio library, which is "a cross-platform C++ library for network and low-level I/O programming that provides developers with a consistent asynchronous model using a modern C++ approach". This documentation page shows several examples on how to use asio. You can use Objective-C++ (with *.mm files) to mix Objective-C with C++.
I want to write some native C/C++ code that takes some uncompressed PCM audio data and plays it out through my speakers on Ubuntu Linux 12.04. Can you tell me what are the different default audio APIs/libraries that are installed? What is their low-level architecture and how do they interarct with the kernel? (which syscalls)
(I've heard different terms like ALSA, PulseAudio, OSS, and so on, but I don't really have a clear picture of which does what and how they fit together.)
On Linux, you have LOTS of Linux audio APIs to choose from. Here is a graph I made a few years ago demonstrating the relationships among the various Linux audio APIs.
However, if you are only targeting Ubuntu Linux and using C/C++, and you don't need anything too fancy (just taking raw PCM data and shoving it out to the speakers), I would recommend using PulseAudio and sticking to the "simple" API. A trivial example can be found here. It's the path of least resistance to getting a proof of concept working.
In very simple terms, ALSA provides the low level infrastructure for audio in Linux, and Pulse provides the higher (more desktop-friendly) level. As far as most mainstream Linux distributions are concerned (Ubuntu included), OSS is obsolete.
You ask about syscalls. You don't use audio in Linux via syscalls. If you choose to use ALSA directly (not a good idea for simple audio playback), you'd employ its userspace library libasound2 (even OSS would be used via /dev/ files rather than syscalls).
If you are targeting modern Linux distros only, consider using the Pulse API. If you want more flexibility as to what distro you are targeting and the potential for cross-platform support, you could try a library which abstracts away the OS-specific audio API - for example, PortAudio (http://www.portaudio.com/).
If you've never done any audio development, you may find a library such as PortAudio easier to work with than addressing PulseAudio directly.
FMOD should be great for you. It's fairly easy to integrate to any C++ project (and many more languages) and runs under Windows, Linux (32bit and 64bit), Mac, Android, PS3, Xbox, etc. Also FMOD Ex provides both a low-level API and data-driven API.
It is free to use if you are not planning on making money with your application. Otherwise you might have to pay for a license starting at about 100$.
So in Windows, you can use the PlaySound function to play an MP3 file in a C++ application. What would be some similar functions available for use in Mac OS X/Linux? I would also appreciate it if you could link to some sample Hello-World type programs demonstrating this.
You can just open("/dev/dsp") and write to it. That's as "native syscall" as you can get, I believe.
Concerning Audio: Linux != Mac, so I will answer both separately.
MacOS uses the core audio framework for low level audio. Building on that there are several higher level APIs. If you just want to play a sound file the AV Foundation Framework is most likely the way to go. Here you find an example to build a simple app for iOS, which can be ported to MacOS easily.
For Linux the whole situation is quite delicate. There exist many different frameworks and libraries and it very unclear which is low and which is high level, since some of them are emulating the others. Basically there is ALSA and OSS for low level audio. Both of them are crap. Jack is aiming to provide a framework for professional audio but it's not very portable (at least if you are interested in embedded devices). Most Linux OS currently are using PulseAudio as their audio server, which has also a simple API for just playing a single sound and a very difficult API for low level stuff. And then there is the gstreamer library, which is rather portable and has a half way descent API and is especially designed for playing audio & video files and streams, and so probably the way to go on linux.
I personally recommend to use PortAudio, which is a library that provides – as the name states – an audio framework which is portable across several operating systems and audio frameworks. PortAudio is also well designed and has a simple but flexible API.
Well, I'm not sure if current desktops have some more advanced services/libraries that play audio files, but if you really want to do some low-level OS audio output, start looking here. Maybe this is a little too low-level for your needs.
I am looking for a portable (Linux, Windows, Mac OS X) way to play either OGG or AAC (and WAV) files.
I have tried closed source options like FMOD but the license is too costly.
I have tried open source projects like Audiere but it doesnt work well in post OSS Linux distros and has not been updated, according to the site since 2006.
I have considered trying to find a solution for each platform and just abstract them in a class, but I havent found info on the best way to do this on each platform.
I do not need any special functionality, i just want to play/stop the audio files. (In C++)
Any recommendations?
How about OpenAL?
http://connect.creativelabs.com/openal/
Getting audio out to the device portably can be done using PortAudio. For a fully decoding and playback solution have a look at GStreamer.
Consider GStreamer, a cross-platform solution for dealing with multimedia stuff. There are C++ bindings through QtGstreamer.
This post discuss the setup on Windows.