Author Topic: BASSMIDI MIDI I/O Functions  (Read 9199 times)

Art60

  • Posts: 137
BASSMIDI MIDI I/O Functions
« on: 9 Jul '10 - 09:39 »
Hi Ian,
You told us, years ago, that Midi "I/O", or should I say "Input" at least, would be possible in a future BASSMIDI version.
Did you think of it since yesteryear?
I already know Bass.net has something that would help me but I'm not fan of .net so this is why I'm asking you,

Best regards,
Arthur.

Ian @ un4seen

  • Administrator
  • Posts: 23404
Re: BASSMIDI MIDI I/O Functions
« Reply #1 on: 9 Jul '10 - 16:15 »
I'm fairly sure I only ever said that MIDI input support was a possibility, ie. not definite. Having said that, I'll look into it next week :)

Art60

  • Posts: 137
Re: BASSMIDI MIDI I/O Functions
« Reply #2 on: 9 Jul '10 - 17:09 »
Thank you very much, Ian.

Looking forward to reading more about your point of view.

Best regards,
Arthur.

Ian @ un4seen

  • Administrator
  • Posts: 23404
Re: BASSMIDI MIDI I/O Functions
« Reply #3 on: 14 Jul '10 - 15:06 »
Here's an update to try...

   www.un4seen.com/stuff/bassmidi.zip

It adds the following functions... BASS_MIDI_InGetGeviceInfo to enumerate available MIDI input devices, BASS_MIDI_InInit to initialize a device, BASS_MIDI_InStart to start a device, BASS_MIDI_InStop to stop a device, BASS_MIDI_InFree to free a device, and a MIDIINPROC callback function to receive the MIDI data. It also adds the ability to play raw MIDI event data, via a new BASS_MIDI_StreamEvents function. An updated SYNTH example is included to demonstrate that new stuff.

It hasn't been tested very much yet, so please report how you get on with it.

Art60

  • Posts: 137
Re: BASSMIDI MIDI I/O Functions
« Reply #4 on: 14 Jul '10 - 17:41 »
Hi Ian,
I didn't expect you to implement these functions this soon, thank you very much.

So first try : Jazz++ sequencer sends to MidiYoke #1, Synth.exe listens to same channel.

First impression : latency seems very good, have to test it with my own fingers though ;)

Second thing, the mid file I'm playing has two notes playing at the same time and sometimes, one doesn't strike, and rarely, none strike at all.
If you want, please have a llok at b9_2.mid in your incoming folder.

I'll have to implement this dll in a program in order to find where the bug comes from.
I haven't got too much time at this moment but I hope I could send you some more consistent comments soon.

Second try : Axiom 61 keyboard plugged into one of my USB ports:
Every thing works pretty well, aftertouch does work too ;)
Got a weird fader #8 behaviour, changes preset, bend and things like that  ??? have to find which CC it's got, coming later with more info.
And I do confirm : latency is *very* good, its very playable!

Thanks a lot again, Ian.

Have a good july 14th (our time to celebrate) ;)

Regards,
Arthur.

Gamo

  • Posts: 97
Re: BASSMIDI MIDI I/O Functions
« Reply #5 on: 18 Jul '10 - 14:53 »
I do not get it work with MIDI I/O.
I use Maple MIDI port In to receive MIDI stream.
I running synth.exe on windows 7 32 Bits.
Playing with PC's keyboard is work fine.

Ian @ un4seen

  • Administrator
  • Posts: 23404
Re: BASSMIDI MIDI I/O Functions
« Reply #6 on: 19 Jul '10 - 16:49 »
Second thing, the mid file I'm playing has two notes playing at the same time and sometimes, one doesn't strike, and rarely, none strike at all.
If you want, please have a llok at b9_2.mid in your incoming folder.

That file appears to use MIDI channels 1 & 2. The SYNTH example currently only uses 1 MIDI channel (ie. it will only play events on MIDI channel 1), but here's an update that will use 16 channels (note channel 10 won't default to drums)...

   www.un4seen.com/stuff/bassmidi.zip

Let me know if you still have trouble with the file.

Second try : Axiom 61 keyboard plugged into one of my USB ports:
Every thing works pretty well, aftertouch does work too ;)
Got a weird fader #8 behaviour, changes preset, bend and things like that  ??? have to find which CC it's got, coming later with more info.

Sounds funky. Please post the data that you receive (in the MIDIINPROC) for it.

I do not get it work with MIDI I/O.
I use Maple MIDI port In to receive MIDI stream.
I running synth.exe on windows 7 32 Bits.
Playing with PC's keyboard is work fine.

Did you choose the correct MIDI input device in the SYNTH example, and is the MIDIINPROC receiving data? If so, perhaps the device is not sending the data on MIDI channel 1? The updated SYNTH example above should help, if that is the case.

rv

  • Guest
Re: BASSMIDI MIDI I/O Functions
« Reply #7 on: 21 Jun '11 - 01:43 »
The BASS_MIDI_InInit returns BASS_ERROR_NOTAVAIL With MIDI MAPLE VRITUAL CABLE

It is working with my usb/midi interface.

Why?

Ian @ un4seen

  • Administrator
  • Posts: 23404
Re: BASSMIDI MIDI I/O Functions
« Reply #8 on: 21 Jun '11 - 17:33 »
Is it working with other software? If so, I think I'll have to send you a debug version to find out what's going wrong with BASSMIDI.

rv

  • Guest
Re: BASSMIDI MIDI I/O Functions
« Reply #9 on: 21 Jun '11 - 17:58 »
Yes, it is working with other softwares.
Note that I am using vb.net with bass.net

rv

  • Guest
Re: BASSMIDI MIDI I/O Functions
« Reply #10 on: 29 Jul '11 - 01:39 »
Hi,

I am using VB.NET

On the BASSMIDI MIDIINPROC, I get the buffer as a pointer address value, but how can I get the events themself, like NOTE ON, NOTE OFF..

I want to do some process before sending them, for example I receive on the MIDIINPROC a C3 midi note, and want to send to the BASSMIDI SF2 engine a C#3

How to do it?

Dan

Ian @ un4seen

  • Administrator
  • Posts: 23404
Re: BASSMIDI MIDI I/O Functions
« Reply #11 on: 29 Jul '11 - 15:10 »
The MIDIINPROC receives raw MIDI event data. For example, C3 note on with velocity 100 on channel 1 would look like this: 0x90 36 100. To make that a C#3, you would change the 36 to 37. You can find details here...

   www.sonicspot.com/guide/midifiles.html

After you have modified the data, you can use BASS_MIDI_StreamEvents (mode=BASS_MIDI_EVENTS_RAW) to play it in a BASSMIDI stream.

rv

  • Guest
Re: BASSMIDI MIDI I/O Functions
« Reply #12 on: 3 Aug '11 - 23:41 »
I think the problem is more a .net question for Radio42

The MIDIINPROC Buffer argument seems to be a pointer address to the raw data and not the raw data itself.

My question is how to get the raw data itself for example  0x90 36 100  ....

The BASS.NET help says :
buffer
Type: System.IntPtr
Pointer to the MIDI data.

radio42

  • Posts: 4710
Re: BASSMIDI MIDI I/O Functions
« Reply #13 on: 4 Aug '11 - 08:08 »
Dealing with a MIDIINPROC is like dealing with a DSPPROC!
In the DSPPROC you receive a pointer to the actual raw PCM sample data.
In the MIDIINPROC you receive a pointer to the actual raw midi data.
Midi data is a byte[], the length parameter tells you the number of bytes.

Here are two examples on how to retrieve the data (for more examples see the Bass.Net docs, incl. the chapter 'Marshaling and Memory Access')!

Data Access using Marshal.Copy:
Code: [Select]
private void MyMidiInProc(int device, double time, IntPtr buffer, int length, IntPtr user)
{
    byte[] midiData = new byte[length];
    // copy from unmanaged to managed memory
    Marshal.Copy(buffer, midiData, 0, length);
    // use the midiData as you need it
    ...
}

Buffer Access using Pointers in an unsafe code block (C# only)
Code: [Select]
private unsafe void MyMidiInProc(int device, double time, IntPtr buffer, int length, IntPtr user)
{
    byte *midiData = (byte*)buffer;
    for (int i=0; i < length; i++)
    {
        Console.WriteLine("Value at {0} is {1:X}", i, midiData[i]);
    }
    ...
}

dj joy

  • Posts: 25
Re: BASSMIDI MIDI I/O Functions
« Reply #14 on: 7 Nov '11 - 14:36 »
Hi,

The midi in works perfectly. When update bassmidi.dll for midi out ?

Best Regards and great job !!




Ian @ un4seen

  • Administrator
  • Posts: 23404
Re: BASSMIDI MIDI I/O Functions
« Reply #15 on: 7 Nov '11 - 17:33 »
When update bassmidi.dll for midi out ?

Do you mean hardware MIDI output? If so, I'm afraid there are no plans for that currently, as BASSMIDI is primarily a softsynth. I think BASS.Net does include hardware MIDI output support though, if you're using that. Alternatively, you could implement it yourself using the midiOut/Stream functions, or even MCI if you simply want to play a MIDI file.

dj joy

  • Posts: 25
Re: BASSMIDI MIDI I/O Functions
« Reply #16 on: 8 Nov '11 - 15:10 »
I want to send to midi devices (like hercules) to light on leds, etc.
I try bassmidi to get data from midi devices and works really fine.

I want send messages to external devices.

Sorry for my english.

Best regards,

Ian @ un4seen

  • Administrator
  • Posts: 23404
Re: BASSMIDI MIDI I/O Functions
« Reply #17 on: 8 Nov '11 - 17:22 »
OK. In that case, I think the midiOutShortMsg function is what you want...

   http://msdn.microsoft.com/en-us/library/windows/desktop/dd798481.aspx

radio42

  • Posts: 4710
Re: BASSMIDI MIDI I/O Functions
« Reply #18 on: 9 Nov '11 - 09:40 »
This is also what Bass.Net is internally using when sending a MIDI ShortMessage to a MIDI-Output device (midiOutShortMsg).

dj joy

  • Posts: 25
Re: BASSMIDI MIDI I/O Functions
« Reply #19 on: 10 Nov '11 - 06:15 »
In Windows, I have Delphi components to handle midiout and  midiin.
I translate my program to Lazarus (FreePascal) because is multiplatform.
In windows i haven't problem to manage midi i/o with Lazarus. I can use delphi components.
But in my second platform of choice (Linux) it's very difficult to handle midi i/o (and more dificult from freepascal, because some examples are in c).
On the Mac I have to investigate yet.

If in the future midi i/o is implemented in bassmidi will be a great help for programmers who want to develop cross-platform, using the same source code.

Best Regards,


dj joy

  • Posts: 25
Re: BASSMIDI MIDI I/O Functions
« Reply #20 on: 20 Jan '12 - 06:58 »
Is dificult create in bassmidi output?
IAN, Are you think on manage output in bassmidi on next updates?

Thanks.

Best regards

Ian @ un4seen

  • Administrator
  • Posts: 23404
Re: BASSMIDI MIDI I/O Functions
« Reply #21 on: 20 Jan '12 - 16:28 »
I'm afraid there are still no plans for hardware MIDI output support in BASSMIDI at the moment.

David_AVD

  • Posts: 39
Re: BASSMIDI MIDI I/O Functions
« Reply #22 on: 13 Feb '21 - 09:24 »
Is it still the case the BassMidi is only for synth type work?

I was looking to play MIDI files to hardware outputs.

I also need to send MIDI messages to and receive them from hardware (or virtual loop) devices.

Ian @ un4seen

  • Administrator
  • Posts: 23404
Re: BASSMIDI MIDI I/O Functions
« Reply #23 on: 15 Feb '21 - 16:47 »
BASSMIDI does have support for MIDI hardware input (see BASS_MIDI_InInit), but not output support I'm afraid.

rv

  • Posts: 329
Re: BASSMIDI MIDI I/O Functions
« Reply #24 on: 15 Feb '21 - 20:34 »
I see this is a frequent question. I am curious why you don't add MIDI OUT support, as you already done the work for the MIDI IN? MIDI IN seems to more complicated than MIDI OUT, especially for receiving sysex

I myself use direct Windows functions, so I don't need it now, but if one day I decide to create software for other platforms, then it will be really interesting, to not have to study MIDI functions on every platforms, and just adapt the windows code

MidiOut_Open / MidiOut_Close / MidiOut_SendShortMessage / MidiOut_SendLongMessage and enumeration of MIDI OUT devices ...