Developing Midi Sequencers.

Discussion in 'Software' started by DoubleSharp, Aug 11, 2020.

  1. DoubleSharp

    DoubleSharp Platinum Record

    Joined:
    Oct 20, 2015
    Messages:
    235
    Likes Received:
    166
    I was wondering if anyone had an pointers on developing software for midi generators, arpeggio or chord creators.

    What kind of tooling would best to use across all platforms? I like JS and the WebAudioApi but doubt it's possible to port.

    Ideally I would want to be able to run things inside a DAW as a plugin, does that mean having to go 'native'???

    What should I read up on regarding midi parsing, writing?

    Is Midi the way to go or is it worth considering MusicXML?

    Thanks.
     
    • Interesting Interesting x 2
    • List
  2.  
  3. Qrchack

    Qrchack Rock Star

    Joined:
    Dec 15, 2015
    Messages:
    797
    Likes Received:
    338
    Location:
    Poland
    MusicXML is for music notation, not for MIDI. The kind that gets printed.

    MIDI effects like generators, arpeggio, chord creators are not a fit for JS and WebAudioAPI, unless you like a separate browser window and sending MIDI to a hardware synth. What you want is a native plugin (VST/AU). Look up JUCE or iPlug.
     
    • Agree Agree x 1
    • Interesting Interesting x 1
    • List
  4. Xupito

    Xupito Audiosexual

    Joined:
    Jan 21, 2012
    Messages:
    6,983
    Likes Received:
    3,855
    Location:
    Europe
    If you want to develop a plugin, I would start with programmable plugins:
    - Reaper ReaJS: https://www.reaper.fm/reaplugs/
    It's a standalone version of Reaper native ReaJS plugin (JS stands for Jesusonic, not JScript). The language (EEL2) is very weird but it's free and fast. Lots of examples

    - Blue Cat's Audio Plug N'Script: https://www.bluecataudio.com/Products/Product_PlugNScript/
    This one uses a script version of C/C++ as language. Porting them to native C++ is easy.

    Keep in mind when going native (all C++) there's a lot more things to do than in those two. JUCE is the way to go IMHO but still, if you come from JScript/WebAudioAPI is very hard. And the GUIs, well... :crazy:

    MusicXML is just a standard format to write all kind of Midi stuff. If you develop an app that reads/writes midi files you'll use them. There's libraries for them in several programming languages. I'm guessing when you said Midi you were talking about .mid files.
     
    Last edited: Aug 11, 2020
    • Like Like x 1
    • Interesting Interesting x 1
    • Useful Useful x 1
    • List
  5. DoubleSharp

    DoubleSharp Platinum Record

    Joined:
    Oct 20, 2015
    Messages:
    235
    Likes Received:
    166
    Thanks for the info.


    This is kind of my case, 'unless you like a separate browser window and sending MIDI to a hardware synth.' I just wondered how tough it would be to 'port' an idea from Browser to Plugin.

    Yeah, I'd like to be able to just midi into whatever synth. I guess there's nothing wrong with Dragging and Dropping midi files around your file system. It's just not very fun.

    I guess DAW plugins are hard because of the GUI.

    This video on the iPlug main page goes into quite a bit of detail around 35 min regarding the problems and potential solutions of WebAudio and CPP. Particularly interesting stuff...



    I just wondered how difficult it would be to release something downloadable which would sit inside a DAW. Answer: VERY! Especially if you want a pretty and effective GUI.

    The project I had in mind would be relatively simple to achieve with Web Stuff. I thought it might be fun to try my hand at learning something new. With WebAssembly now here I was wondered how things were on the 'proper' side of things. If they were lowering the barriers to development on the native side.

    Thanks again for the info.
     
  6. SineWave

    SineWave Audiosexual

    Joined:
    Sep 4, 2011
    Messages:
    4,302
    Likes Received:
    3,404
    Location:
    Where the sun doesn't shine.
    When it comes to VST GUI, this is one of the best and most popular developer tools: VSTGUI

    JUCE is also great [or even better], but you need to pay for the license to use it. I don't think there is a free version of it.

    When it comes to developing a DAW, there's not much to think IMO: C++

    When it comes to MIDI, you should also consider OSC [Open Sound Control] as a standard for controlling interfaces.

    You really need to get into C++ or Python at least, to develop cross-platform music tools. JS won't do. You need to learn some lower level language than that.

    Just my 2p. :wink:

    Cheers!
     
    • Agree Agree x 1
    • Interesting Interesting x 1
    • List
  7. Xupito

    Xupito Audiosexual

    Joined:
    Jan 21, 2012
    Messages:
    6,983
    Likes Received:
    3,855
    Location:
    Europe
    JUCE has a free GPL-style version totally functional for non-commercial projects. In the latest version (v6) you don't even have to include analytics (JUCE's own spyware), which was a limitation for the free version.

    BTW, using WebAudio JScript API you can do really cool things, especially with MIDI since requires less resources.
    I still don't fully get the midi files thing.
    FWIW, if you just want to connect the browser with the DAW you can use any virtual MIDI soft/driver. It'll appear as a regular MIDI device in the browser WebMidi API. Just like any MIDI app (not plugin, standalone)

    Anyways, why don't you try some MIDI examples of ReaJS or Plug N'Script? With your JScript level I think you could do interesting stuff with Plug N'script
     
    Last edited: Aug 11, 2020
  8. Qrchack

    Qrchack Rock Star

    Joined:
    Dec 15, 2015
    Messages:
    797
    Likes Received:
    338
    Location:
    Poland
    It is not. It's a standard format to write music notation. It has nothing to do with playback or sequencing, it's all about how it's displayed as notes.
    Not tough. Actually, it's web technologies that are not widely supported (as in: usually Chrome only first, then maybe Firefox when it catches up) and change all the time because they can't agree on anything and it takes years to complete a spec. Remember the host, web or DAW, anything, is just a host. The only thing it does is give you MIDI data in and spit your MIDI data out. That's it. You don't have to learn much there, it's usually in the examples and/or documentation. Once you figure out where's your MIDI in and out, it's all your code anyway and the hardest part is actually deciding what you want to do. GUI is not hard either, just look at examples. The hardest part that will take you the most time is designing the sequencer part.
    You can work with any of these then. Keep in mind web-based stuff will be standalone only - you'll have to get the audio back from your synth on your own. Plus you won't be able to use your sequence in a DAW setting, and it won't be saved with your project.
    Not at all. That's what frameworks like JUCE and iPlug are for. They provide ready to use GUI code and ready to use plugin code which gives you all you need right away. It's the easiest, once you get up and running you'll learn the problem is you have no idea what you want to do in the actual sequencer part.
    You literally download the framework, add the required SDKs/dependencies and hit compile. That's 10 minutes of setup to get a volume knob already working in your DAW. And it will work across VST/AU both Mac and PC. Don't worry about this stuff, it's trivial. Spend your time on thinking about how you do the sequencing part instead.
    It's no different from JavaScript. It's a programming language. You have variables. You have arrays. You have functions. You look in documentation to see what functions you have, you copy paste them and change things around. Then you end up with a plugin that has all the knobs and buttons, and now you have to decide what variables you need for the sequencer steps, what the knobs do, etc. In technical terms, with audio it's like the DAW executes your "main()" function and it has parameters like input array, output array and number of channels (for stereo, that's 2 channels - left and right). Your job is to take the input array (of double variables), do stuff with it, and save the result in the output array. End of story. All the DAW integration stuff is done for you, the only thing you do is work with the audio. And add additional candy like provide presets, saving/loading of them, etc. You use functions from the documentation to do that. Just like any other framework or any other API. It's no different than switching from React to Vue, or whatever you use. Just read the documentation, try the examples and realize you don't know yet what you want to do and then work on where the actual problem is.
    It's not the best and not the most popular. Your GUI will work only with VST. For commercial projects, you can't waste your time creating a separate project for the AU or AAX version. VSTGUI does the job for simple projects (like the various freeware plugins), but it's not really used in the industry - this needs to be abstracted away by a framework that works with all platforms. It's either JUCE (*very* popular in the industry), iPlug (not as popular, but still notable) or some in-house developed one.
    You don't. While playing on your own (without releasing), nobody cares. When you're ready to release, you can choose either to display a JUCE logo when your plugin starts, or pay the license fee, or to release your plugin as open source. The last option doesn't prevent you from selling your plugin, you just have to share the source code so anybody who knows JUCE can compile it (and possibly create a modified version, even sell it, but also sharing the source code).
    It's what everyone uses, but there are options to cross-compile if you're really desperate and insist on using what you're more comfortable with. This will be harder, take more time and likely reduce your options though - so you will spend more time looking for learning resources and trying to find why X doesn't work for you.
    You should not. The only DAWs which natively support OSC are Logic and Reaper. That's it. Everyone else is stuck with MIDI at this point. Cutting out 90% of the market right at the start is not a good idea. Besides, OSC has no advantages for a sequencer, it doesn't have any more resolution in terms of note data. Interfacing with hardware synthesizers will have to be done with MIDI as well.
    You could start with JS, but you probably will spend more time learning how to do a simple test plugin. And you likely won't find much help or information anywhere. Ultimately probably not worth it, but it technically can be done.
     
    • Love it! Love it! x 2
    • Like Like x 1
    • Agree Agree x 1
    • List
  9. Xupito

    Xupito Audiosexual

    Joined:
    Jan 21, 2012
    Messages:
    6,983
    Likes Received:
    3,855
    Location:
    Europe
    Deleted: too tired to reply so many things :rofl:
     
  10. DoubleSharp

    DoubleSharp Platinum Record

    Joined:
    Oct 20, 2015
    Messages:
    235
    Likes Received:
    166
    Wow, thanks everybody.

    Lots of great information coming out.

    First off let me get one thing mega clear. The idea I have is purely for generating MIDI. So this means zero DSP.

    I was thinking MusicXML purely because it may be easier to write, a kind of cut-corner, before I had even started, to simplify writing MIDI. A long time ago I knew more about midi, I don't have a fond memory of it.

    I've had a few ideas (that i've lifted over the years) regarding different but related subjects. Fairly recently they kind of merged, problems that solved each other. Would love to say more and share, I ain't bothered about potential money or kudos. Though just typing that makes me think maybe I am! Can you patent User Interface/App ideas?

    To be honest it is likely to be a pretty big waste of time, it might be absolutely useless. It's more of an experiment.

    The idea I have is kinda visual algorithm-based music generation. So the main GUI wouldn't really be Knobs and Keyboards. It'd be a fair whack of geometry. I was thinking OpenGL or SVG lib would be enough to run inside a DAW as a plugin.

    I was half-thinking of pitching the idea to a remote coding group I sometimes join, usually C# and dotnet. FWIW I'm pretty crap with C#. But that was why I was really wondering about cross platform development. How difficult could it be to satisfy all these different platforms demands? That would be the main challenge. I didn't realise C++ was so dominant in area. Thought Java or C# would've had a shout.

    Ha! You overestimate me!! So I have a main binary that the DAW runs, the binary opens a seperate GUI window and all is presets! Simple!

    Seriously, thanks for everyones input. If I ever get round to trying to implement my plan I'll let you know how I get on.

    I came across this webaudio app and was wondering what options there were available for developing similar things for DAWs

    https://apps.musedlab.org/groovepizza/?museid=jxGaco0wO&
     
    Last edited: Aug 11, 2020
  11. DoubleSharp

    DoubleSharp Platinum Record

    Joined:
    Oct 20, 2015
    Messages:
    235
    Likes Received:
    166
    Thanks for this. Would this work in reverse? Stream the midi From the browser to the DAW?

    Interesting discussion here.

    https://github.com/WebAudio/web-midi-api/issues/45
     
  12. Xupito

    Xupito Audiosexual

    Joined:
    Jan 21, 2012
    Messages:
    6,983
    Likes Received:
    3,855
    Location:
    Europe
    Sure thing. I'm not updated with the current state of WebAudio/Midi stuff, so just in case take a look at those links.
    Even for relatively light stuff like MIDI effects you'd need to watch out the latency that implies the JScript processing, because it could be too much and since it's not a plugin the DAW can't take care of it.

    Having a background somewhat similar to yours I think that it's quite harder to use JUCE and program a native plugin than @Qrchack says.
    It sure is the case with middle-experienced C++ developers, like probably himself, but is another beast than JScript GUIs/audio.

    Edited: I took a quick look at that thread:
    https://github.com/WebAudio/web-midi-api/issues/45
    It's about things you don't need as long you install a virtual MIDI driver.
     
  13. Qrchack

    Qrchack Rock Star

    Joined:
    Dec 15, 2015
    Messages:
    797
    Likes Received:
    338
    Location:
    Poland
    In terms of native development, I'm more familiar with iPlug (because of the more flexible licensing), a simple volume knob plugin looks like this:

    Code:
    #include "IPlugEffect.h"
    #include "IPlug_include_in_plug_src.h"
    #include "IControls.h"
    
    IPlugEffect::IPlugEffect(const InstanceInfo& info)
    : Plugin(info, MakeConfig(kNumParams, kNumPresets))
    {
      GetParam(kGain)->InitDouble("Gain", 0., 0., 100.0, 0.01, "%");
    
    #if IPLUG_EDITOR // http://bit.ly/2S64BDd
      mMakeGraphicsFunc = [&]() {
        return MakeGraphics(*this, PLUG_WIDTH, PLUG_HEIGHT, PLUG_FPS, GetScaleForScreen(PLUG_HEIGHT));
      };
     
      mLayoutFunc = [&](IGraphics* pGraphics) {
        pGraphics->AttachCornerResizer(EUIResizerMode::Scale, false);
        pGraphics->AttachPanelBackground(COLOR_GRAY);
        pGraphics->LoadFont("Roboto-Regular", ROBOTO_FN);
        const IRECT b = pGraphics->GetBounds();
        pGraphics->AttachControl(new ITextControl(b.GetMidVPadded(50), "Hello iPlug 2!", IText(50)));
        pGraphics->AttachControl(new IVKnobControl(b.GetCentredInside(100).GetVShifted(-100), kGain));
      };
    #endif
    }
    
    void IPlugEffect::ProcessBlock(sample** inputs, sample** outputs, int nSamples)
    {
      const double gain = GetParam(kGain)->Value() / 100.;
      const int nChans = NOutChansConnected();
     
      for (int s = 0; s < nSamples; s++) {
        for (int c = 0; c < nChans; c++) {
          outputs[c][s] = inputs[c][s] * gain;
        }
      }
    }
    GetParam()->InitDouble makes your parameter visible in the DAW (for automation, saving settings, etc).
    Then there are layout things, like setting fonts, adding text etc. And the main function which does the audio. It's the same for MIDI, you just get different parameters in the function. You don't have to write the template above, it's auto generated and you replace it with what you need.

    The above code results in this:
    [​IMG]
    I used the standalone version because of convenience, it looks the same in a DAW, just with typical borders the DAW adds to every plugin. This compiles without any problems for VST2, VST3, AU, AAX (Pro Tools) for both Windows and macOS (from the same code as posted above). There is some iOS AU support, I don't know how well it works though.

    Edit: for MIDI effects it looks like this:

    Code:
    void IPlugMidiEffect::ProcessMidiMsg(const IMidiMsg& msg)
    {
      int status = msg.StatusMsg();
     
      switch (status)
      {
        case IMidiMsg::kNoteOn:
        case IMidiMsg::kNoteOff:
        case IMidiMsg::kPolyAftertouch:
        case IMidiMsg::kControlChange:
        case IMidiMsg::kProgramChange:
        case IMidiMsg::kChannelAftertouch:
        case IMidiMsg::kPitchWheel:
        {
          SendMidiMsg(msg);
        }
        default:
          return;
      }
    }
     
    Last edited: Aug 13, 2020
  14. lbnv

    lbnv Platinum Record

    Joined:
    Nov 19, 2017
    Messages:
    325
    Likes Received:
    179
    @DoubleSharp

    Avoid MusicXML. Synths (real or virtual) and DAWs understand MIDI. Do they understand MusicXML? No. Not all. Most of them don't. It's just an additional layer of abstraction you don't need.
     
Loading...
Similar Threads - Developing Midi Sequencers Forum Date
Tone2 is no longer developing new plugins, but is not going out of business Industry News Mar 10, 2024
Behringer has begun developing a free DAW Software News Mar 9, 2020
Questions about developing third party plugs in for DAW's Software May 18, 2016
WOK to stop developing plugins Lounge Apr 30, 2015
How do you approach on developing a new Library? Kontakt Apr 22, 2015
Loading...