How to use mac's default midi sequencer as midi out? - c++

I have been trying to play midi voices with rtmidi. I have sucessfully managed to link it and compile example programs. But unfortunately I can't see my snow leopards own midi sequencer as an output port. I also tried to open a midi output port using the coremidi library with no success.
How can I make rtmidi or another library send it's messages directly to the apple's own midi sequencer?
Should I start a midi out server? If so, how can I do it?
Any help would be greatly appreciated.
PS: I am trying to send these messages and play those voices to turn my computer keyboard in a musical instrument.

So you are just interested in generating midi notes from the desktop keyboard and playing them back locally? You don't need to deal with output ports, RTMidi or anything like that. You would only need to that if you wanted to send message events to an external synth.
See this PlaySoftMidi Apple sample code for generating notes through the soft synth. If you want to load your own sound library (sound font 2 or DSL) search for "AUSampler" and "MusicDeviceMIDIEvent" - there are a few tutorials out there (link)

Related

Pi 3 USB USB Microphone; accessing programmtically in C/C++

I am doing a speech processing project with a Raspberry Pi 3 (running Raspbian) using a USB Microphone. I can see the Microphone show up as a selectable audio device for the Pi and it produces/captures sound perfectly.
I cannot figure out how to use this in my code; I have done a ton of research regarding this and have found some tutorials but nothing that making sense. I come from more of a hardware background and have done something like this with controllers where I hook up an actual Mic and process the Analog Signal into Digital on IO Pins; I am so frustrated with this that I am about to pump data over from an Arduino using a Mic and A2D conversion.
-------------------------------------------------------My questions----------------------------------------------------
1) I want to know how to access a USB data stream or USB device in C or C++. My Linux abilities are not the best. Do I open a Serial Connection or open a filestream in "/dev/USB/...."? Can you provide a code example?
2) Regardless of the fidelity of the USB Mic Input, I want to know how to access its Input in C/C++. I have been looking at ALSA but cannot really understand a lot of its complexity. Is there something that gives me access to a raw input signal on the USB Port that I can process ( where I extrapolate out frequency, amplitude, etc.)?
I have already gone through a lot of the similar posts on here. I am really stuck on this one. I 'm really looking to understand what is going on from the OS perspective; I'll use a library given but I want to understand how it works.
Thanks!
So an update:
So I did all of my code in C with some .sh scripts. I went ahead and figured out how to use the Alsa asoundlib (asound.h specifically). As of now, I am able to generate and record sound via USB Mic/Headset with my Pi 3. Doing so is rather arduous but here is a useful link (1).
For my project, I also found a CMU tutorial/repos for their PocketSphinx Audio Recognition Device at link (2) and video link (3). This project utilizes the Alsa asoundlib as well and was a great help for me. It takes a while to download and you need to crawl through its .sh scripts to figure out its gcc linking. But I am able to now give audio cues which are interpreted by my Pi 3 and pushed to speaker output and GPIO pins.
LINKS(1)http://www.alsa-project.org/alsa-doc/alsa-lib/_2test_2pcm_8c-example.html
(2)https://wolfpaulus.com/embedded/raspberrypi2-sr/
(3)https://www.youtube.com/watch?v=5kp5qpwVh_8

Audio Streaming C++ Server / Client

I am actually working on a server-client multimedia player. This player can be a server to stream a MP3 file (or wma, wav, ogg, flac ...) over the network to another player (client).
I worked first on a basic network communication (client-server), that send and receive bits. But I have a problem : the audio encoding. I need a tool to encode the audio data to be able to send a little part of it through the network and let the client play it before the next part is coming.
I saw a few tools on internet such as BASS library, Live555 ... I used to work with PortAudio for student's projects but I hate it.
So basically, I need a tool to encode audio data (server side), (I can send it over lan), and decode data to play it (client-side).
Do you guys have some ideas about how to do it ? Which tool could be useful for me in that case?
PS : I am trying to use Qt library for the network interface (it is efficient, and it works on windows, linux, mac) ... Is there any audio streaming tool included in the Qt library ?
You can try FFMPEG. It can convert almost anything to anything (so it claims) and it is a widely used open source library.
We use it in our application mainly for decoding video/audio streams.

MIDI sniffing + OpenGL in Windows

I'm currently specing out projects for my graphics class and I am thinking of writing an application that displays a visualizer for midi data. What I would like to do is sniff midi data as it passes through the system. I do not want to hijack a driver, only watch the data go by (that is, I want the MIDI data to later be accessible by a DAW). I am not familiar with programatically accessing midi in windows. The closest I could find to what I want seems to be midi spy. However I would prefer to write the app in c/c++.
I was looking at MIDI Stream API, but I can't tell if I'll be able to sniff devices that weren't opened by the library. I was also looking at SDL Mixer and QT Midi. I'm just trying to get some personal pros and cons to the options that I've presented or ones that I haven't found.
Unfortunately, there is no way to actually sniff MIDI streams under Windows. All you can do is place your application between the two MIDI devices.
Unless you are putting software between physical in/out ports, you will need to set up a virtual MIDI loopback driver that directs the MIDI stream data from an input to an output. Fortunately, there are a few off-the-shelf solutions already. The easiest method is to require your users to set up a virtual MIDI port and configure it on their own. LoopBe1 and MIDI Yoke are free.
Another method is to use a virtual MIDI driver that goes directly to your application. Tobias Erichsen has created a very easy-to-use driver for this very purpose. I don't believe he has released it yet, but if you shoot him an e-mail, he might get back to you. See this question: DDK "Hello World"

Using built in general midi on OS X using RtMidi?

I'm trying to write a C++ app which plays midi sounds, but I'm having some difficulty. I got the examples that come with RtMidi to compile out of the box, but running the midiout example, I don't hear anything. Running the midiprobe example I get:
There are 1 MIDI input sources available.
Input Port #1: AudioFire4 (2357) Plug 1
There are 1 MIDI output ports available.
Output Port #1: AudioFire4 (2357) Plug 1
But that's just an audio interface that I use for using multiple speakers. I don't use any of the midi functionality on it.
Does anyone know how to get RtMidi to use the built in system general midi sound bank so that I can actually hear something?
Thanks,
Gabe
If anyone else is curious about this, I ended up installing FluidSynth and downloading the FluidR3 soundfont. That seems to work great. Just run it, and it presents itself as a midi device.

Audiooutput problem in Qt using qmultimedia low level API

I'm trying to get mpg123 audio decoder to work with QT on windows. How do i play the decoded audio data at the right speed with Qmultimedia module in push mode. Currently i'm using simple timer to get it to play audio but it's not very efficient way to do it, if I do anything else at the same time audio get all distorted. Is there any better way to send the decoded data to audio output? It would be nice if anyone could point me to any nice examples using Qmultimedia module and Qaudiooutput class. I've tried to figure out QT example project "audiooutput" but it seems that it's also using timer to send audio to output in push mode.. Hope that I'm not too confusing.
I also had to figure that out and I would also suggest using the Phonon framework to do this.
It uses Windows Media Player as host on Windows, QuickTime on Mac and some KDE stuff on Linux.
So it's pretty platform independent.
If you need more low-level functionality, you should take a look into an open-source project called portaudio. It's very easy to use and you can manipulate or even fill buffers from code.
I used it to build an oscillator.
Hope that helps!
Best,
guitarflow