Thread: Detecting and polling MIDI in devices.

  1. #1
    Registered User samGwilliam's Avatar
    Join Date
    Feb 2002
    Location
    Newport
    Posts
    382

    Detecting and polling MIDI in devices.

    Can anyone help me with reading MIDI input (from a controller keyboard or similar)? I want to write a software synthesiser, I'm having trouble with getting the audio part working (it seems the library I'm using, Port Audio, is basically dead in the water and I don't know what I'm going to do about that).

    So I thought I'd carry on and write everything but the actual audio out part for now (until I come across another method for accessing the sound card for raw sample output).

    So I'll want some way of detecting a MIDI device and events. I've done this with Arduino so I know a bit about the structure of MIDI messages, etc, but no idea how I'd incorporate this into a Windows program.

    Does anyone have any suggestions?
    Current Setup: Win 10 with Code::Blocks 17.12 (GNU GCC)

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User samGwilliam's Avatar
    Join Date
    Feb 2002
    Location
    Newport
    Posts
    382
    Thank you. I gave this a try: MIDI-in sample program for Win32 (using winmm.lib) * GitHub

    And, just like I knew was going to happen, it complained that it couldn't find SDKDDKVer.h. I've never heard of this file and the tutorial just assumes you have it. Yet another bull........ obstacle to just being able to, you know, write code. This is what put me off it for so many years. I just want to code.
    Current Setup: Win 10 with Code::Blocks 17.12 (GNU GCC)

  4. #4
    Registered User samGwilliam's Avatar
    Join Date
    Feb 2002
    Location
    Newport
    Posts
    382
    I found the header file so I thought I'd try and get the winmm.lib file to work with it. I did some Googling and discovered that Mingw has its own version called winmm.a so I put the command line switch "-lwinmm" into the linker options (removing the #pragma comment(lib, "winmm.lib")). Naturally it just generates about a million errors (see pic).

    https://i.ibb.co/LpNQjMN/error.jpg

    All I want is to run a bit of code that says "yes i have received a MIDI message". Why is this such a headache!
    Current Setup: Win 10 with Code::Blocks 17.12 (GNU GCC)

  5. #5
    Registered User samGwilliam's Avatar
    Join Date
    Feb 2002
    Location
    Newport
    Posts
    382
    And the image is, for some reason, too small to read. No idea why that is, sorry. Oh, and, while I'm trying to read the error messages the, after about 12 seconds, the IDE spontaneously opens some random header file and presents me with a different set of error messages so I can't even try and rectify the errors using thinking and reason. It just seems hopeless.

    Can I do all this in Java or something? I've had enough with C++. I remember when I used Turbo C++ in DOS and everything I needed was a #include away. Coding C++ today is just overcomplicated bollocks where people seem to be actively trying to make it as inaccessible as possible.
    Current Setup: Win 10 with Code::Blocks 17.12 (GNU GCC)

  6. #6
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    Yeah, save your screen captures as PNG files.
    Then at least we have a chance of scaling your images to the point where the text is readable.

    Besides, C::B can just copy the console log to the clip-board - try it.
    No fuzzy picture.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  7. #7
    Registered User samGwilliam's Avatar
    Join Date
    Feb 2002
    Location
    Newport
    Posts
    382
    Yeah sorry, I was just throwing my toys out of my pram. This is so frustrating though - all I'm seeing are seemingly unnecessary barriers to the pure pursuit of coding. I did some stuff with Arduino a few years back (until my hopeless grasp of electronics got in the way) and it really felt like a return to the "good old days".

    I'll get back to you with the errors and whatnot at some point but I'm going to take a break for a few days before I smash my laptop.
    Current Setup: Win 10 with Code::Blocks 17.12 (GNU GCC)

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Polling an Array
    By danlee58 in forum C Programming
    Replies: 12
    Last Post: 02-01-2015, 10:17 AM
  2. Replies: 1
    Last Post: 02-22-2010, 11:52 PM
  3. Polling vs. Interrupts
    By NewGuy100 in forum C Programming
    Replies: 4
    Last Post: 09-30-2005, 12:43 AM
  4. keyboard polling
    By krappa in forum Game Programming
    Replies: 16
    Last Post: 06-15-2004, 04:44 PM

Tags for this Thread