Cabbage Logo
Back to Cabbage Site

Not into audio processing, only MIDI and Sequencing

I was wondering if I can use Cabbage/cSound for purely MIDI stuff on an Embedded System. I’m not into audio programming/processing at all. The sound processing/generation is done on an external instrument over Midi.

The closest to my approach was the MIOS32 project, but I need more advanced, fully documented, and highly portable library to work with. I’m not afraid of switching to a more advanced target MPU capable of running Linux so I can utilize the dependencies needed for cSound or Juce. What do you think?

Shouldn’t be an issue. Cabbage runs on Linux, and Csound runs pretty much everywhere. You just need to make sure your device is capable of outputting MIDI.

p.s. welcome to the forum!

Thank you for your reply. Sure, we’re talking about custom hardware so reserving certain UARTs for MIDI should not be a problem for me. Like I said earlier, I’m not concerned about audio processing, DSP, or anything like this for now. All I want to do is to build a simple Midi player, sequencer, pattern player, something like that, that synchronizes to external clock/DAW.

I have made some research, but I’m not sure whether I can use references to other platforms here.

Anyways, for a complete noob in music app development coming from pure embedded environment, do you have any advice on where or how to get started writing my own Midi apps with Cabbage/cSound for an Embedded Linux platform? Do I have to learn ALSA or JACK? Any tips, issues, or whatever cross-compiling Cabbage projects on certain embedded platforms and what build systems do you recommend?

Thank you again for this great contribution to the Audio/Music world and I appreciate your follow up!

On thing just occurred to me, do you need a UI? If not, then I’d drop Cabbage entirely and just use Csound. And I’d start by writing a simple Csound instrument that outputs to a MIDI port. You’ll need to use ALSA MIDI I guess, but Csound comes with interfaces for that. Csound has quite a few opcode for outtputing MIDI:
https://csound.com/docs/manual/MidiOutput.html

Of course, GUI is above everything else. For the current simple box I’m working on, it might do with only cSound and simple UI with a few controls. I guess I can use external GUI lib for this. But I will soon move to something move advanced where I need a lot of control, UI elements, widgets, etc…

If I understand you correctly, cSound Midi core is just a wrapper for ALSA? I believe writing instrument is way different from writing a sequencer or Midi player app. Or did I miss something here?

I have downloaded/installed Cabbage a few weeks ago, but I was afraid of giving it a shot before allowing some time reading the documentation. It seems “instrument” in Cabbage is not an instrument in its essence as I know it from different audio gear. It can be a drum machine, arpeggiator, or even a synth. This seems like everything I need, but I’m still concerned whether I can achieve it with Cabbage or not. But no doubt, it’s worth it. This might be a life changer for me!

An instrument can be a MIDI instrument, a synth, an effect, etc. Everything in Csound comes down to instruments. :slight_smile: Give it a go and see how it goes, if you need UI, then it sounds like Cabbage could be the right tool for the job.

Absolutely, you’re right. :slightly_smiling_face:

I didn’t find any Sequencers or Midi file players in the examples tab. Do you know where I can find more about this?

WOW, just found MiniPops.csd. This is a great one!

I’m afraid Csound doesn’t handle midi file playback so well. It can play back files but you have no control over tempo. You can’t pause playback either. But you can generate your own midi output using whether algorithms you like.

I’ll dig up a sequence for your later. I’m sure I have a few lying around.

That’s what I was afraid about. What I want to make is something similar to the MiniPops example, but instead of playing notes from the Drum Kit selected in the app and forward the Midi events to the synthesis engine, I want to play small patterns (MIDI files) in a fashion similar to that of MiniPops, switching between patterns, sync to ext. clock, changing tempo, etc. And Midi events should be forwarded to external DAW/Synth for playback and generation of sound.

Yeah, in that case I’m not sure Csound will be the right fit. People have worked around this using Python MIDI frameworks to send the MIDI data to Csound, but it’s an extra level of complexity. How are your C++ programming skills? I’ve always thought a MIDI file player would be a nice addition to Csound’s audio file streaming opcodes.

I understand you. Like I said earlier, I’m coming from embedded C background. I’m more experienced with hardware stuff, low-level code, device drivers, and design/layout of product circuit and programming of firmware. However, I believe it won’t be that difficult to do it given the necessary tools and libs. I have access to an old C++ Midi lib from the 90s era, but not sure if that helps.

I’m tempted to look into it myself if I’m honest. Csound already makes use of portMIDI. I might have a little bit of free time later today to take a look.

I threw together a simple MIDI file player, but it’s not going to be as simple as I first thought. The problem is polyphony. This will have to be managed manually, which is never an easy task. Right now the opcode will read a MIDI file and start outputting the notes in realtime, as k-rate variable. Imagine midiin but for a midi file. I will look at how the Csound parses incoming lie MIDI, maybe there is a clue there.

Thank you very much for your time and for all the efforts put forth into this. I didn’t dive too much into cSound, but skimming the floss manual and some of its API documentation, I realized that the MIDI implementation, op-codes, or whatever you call it in cSound, is not what I’m looking for to get me where I want in MIDI, or at least this is what I presume. I believe the time needed to find a workaround to do Midi stuff in cSound is maybe same or less than needed to get things done with another platform with fully-fledged MIDI API. Juce is an example, if you will, but it was always intimidating for me because of its steep learning curve, let alone cross-compilation issues on different ARM targets.

That’s why I started writing a midi file reader opcode. But don’t feel pressured to stay with Cabbage is your don’t think it will fit. I think a midi file reader will be quite useful anyway :+1:

Sure, it is absolutely a useful addition to cSound. I will never abandon Cabbage cause I really can’t abandon it on my table. I’m pretty sure it can help a lot on future projects that involve sound synthesis. I’m now trying to see if I can derive a stripped-down embedded version of any available C/C++ Midi lib for the current job. It would be nice if you have any suggestion. I’m not experienced in JACK/ALSA so I prefer to stay away now from libs with those dependencies.

I would use JUCE, as it’s what I know best, plus you can build your eventual UI around it too. The opcode I wrote today I built with JUCE, which has accessible MIDI classes. You can enable Jack/ALSA support if you like but you probably don’t need to. But make sure the license suits. PortMIDI is a good MIDI library too that is used in a lot of applications. But would a MIDI file player opcode not answer you needs?

Yes, a MIDI file player/parser would probably answer the question, but I would like to take a look at the opcodes available and whether I can build a sequencer with all controls needed using those. Things like time control/tempo, synchronizing the player with external clock, and most controls you usually find in sequencers.