Author Topic: BASSMIDI beta  (Read 45968 times)

Ian @ un4seen

  • Administrator
  • Posts: 20400
BASSMIDI beta
« on: 17 Oct '06 - 16:07 »
Yep, the BASS MIDI plugin has arrived. It comes with C/C++, Delphi and Visual Basic APIs.

   Now available on the BASS page.

It uses SF2 soundfonts to provide the sounds to render the MIDIs with (ie. it's a softsynth). By default, it'll use the Creative/Soundblaster soundfont when available, but any of the many SF2 soundfonts freely available on the 'net can be used. Here's one to get started with (including some demo MIDI files too)...

   www.un4seen.com/download.php?Chorium.exe

To reduce distribution sizes, soundfonts can also be packed (example packer included). Here's a WavPack hybrid encoded version of the same soundfont...

   www.un4seen.com/stuff/Chorium.zip   (BASS_WV add-on required)

Multiple soundfonts can be stacked, and each MIDI stream can have its own soundfont configuration. It'll also automatically load soundfonts of the same name as the MIDI file, like these examples created with 2MIDI...

   www.un4seen.com/stuff/2miditests.zip

It also supports lyrics, which the included MIDITEST example will display. Here's an example file to test with...

   www.un4seen.com/stuff/takelong.mid

See the documentation for further details, and please report any problems/questions/suggestions/etc...
« Last Edit: 14 Nov '06 - 15:19 by Ian @ un4seen »

radio42

  • Posts: 4574
Re: BASSMIDI beta
« Reply #1 on: 17 Oct '06 - 17:02 »
BASS.NET will cover this one too - in one of the next releases of course... ;-)

fred

  • Guest
Re: BASSMIDI beta
« Reply #2 on: 17 Oct '06 - 19:08 »
hello! and thank you for this plugin, it's exactly what I needed ;D
one question, how can I make the plugin to use the file Chorium.sf2 ? At present I have copied this file into my WINDOWS/SYSTEM32 directory and rename it in CT4MGM.SF2 to make it works ::)
I think it should exists another solution ;)

Bye
fred
http://dekibulle.free.fr

(: JOBnik! :)

  • Posts: 1065
Re: BASSMIDI beta
« Reply #3 on: 17 Oct '06 - 19:29 »
Hi ;D

Yep, I already see some errors in VB APIs ;)
When I'll come from work, I'll take a look into :)

SoundMike

  • Posts: 331
Re: BASSMIDI beta
« Reply #4 on: 18 Oct '06 - 04:01 »
 :) Thanks, Ian. I look forward to using it when I get time - and when the VB APIs are OK.

Ian @ un4seen

  • Administrator
  • Posts: 20400
Re: BASSMIDI beta
« Reply #5 on: 18 Oct '06 - 14:54 »
one question, how can I make the plugin to use the file Chorium.sf2 ? At present I have copied this file into my WINDOWS/SYSTEM32 directory and rename it in CT4MGM.SF2 to make it works ::)
I think it should exists another solution ;)

Yep, it does ;)

You need to use BASS_MIDI_FontInit to initialize the soundfont, and then BASS_MIDI_StreamSetFonts to apply it to a MIDI stream. For example...

Code: [Select]
HSOUNDFONT font=BASS_MIDI_FontInit("C:\\path\\to\\chorium.sf2", 0); // initialize soundfont
// apply it to a MIDI stream...
BASS_MIDI_FONT mf[1];
mf[0].font=font;
mf[0].preset=-1; // use all presets
mf[0].bank=0; // use default bank(s)
BASS_MIDI_StreamSetFonts(channel, mf, 1);

Or to change the default soundfont configuration, use 0 instead of a MIDI stream handle ("channel"). Look up these functions in the docs for further details.

:) Thanks, Ian. I look forward to using it when I get time - and when the VB APIs are OK.

Jobby's corrected VB API is in the download now. VB example should be following shortly :)

victor

  • Posts: 124
Re: BASSMIDI beta
« Reply #6 on: 18 Oct '06 - 18:13 »
are there plans to support sending, in real time, plain notes to the dll or is it playing only from a midifile?

radio42

  • Posts: 4574
Re: BASSMIDI beta
« Reply #7 on: 18 Oct '06 - 21:22 »
Nice one - BASS.NET APi almost ready....
But I also would like to request some enhancements ;-)

What about MIDI InputDevice and OutputDevice support. Something like the following would be great:

Input Device:
- Get current Input Device
- Get the name of a certain MIDI input device
- Set the current InputDevice to a certain one
- Open a MIDI InputDevice
- Close a MIDI InputDevice
- Connect a MIDI InputDevice to a MIDI OutputDevice
- Disconnect a MIDI InputDevice to a MIDI OutputDevice
- Start (recording) a MIDI InputDevice (to receive MIDI messages in a callback)
- Stop (recording) a MIDI InputDevice
- bool IsMidiInput open?
- bool IsMidiInput recording?

The "MIDI_RECPROC" should then be able to handle the following MIDI messages in the callback (at best selectable what messages you want to monitor/record via the Start method, see above):
- ChannelMessageReceived
- InvalidShortMessageReceived
- SysCommonReceived
- SysExReceived
- SysRealtimeReceived
- SysExHeaderErrorOccurred


Same for Output Device:
- Get current Output Device
- Get the name of a certain MIDI output device
- Set the current OutputDevice to a certain one
- Open a MIDI OutputDevice
- Close a MIDI OutputDevice
- Reset a MIDI OutputDevice
- Send a message to a MIDI OutputDevice (see above for message types)
- bool IsMidiOutput open?

That would be awesome !!!

Ian @ un4seen

  • Administrator
  • Posts: 20400
Re: BASSMIDI beta
« Reply #8 on: 19 Oct '06 - 18:53 »
are there plans to support sending, in real time, plain notes to the dll or is it playing only from a midifile?

It's not definite, but it's a possibility.

What about MIDI InputDevice and OutputDevice support.

MIDI input is a possibility, but I'm not sure about output... after all, BASSMIDI is a softsynth ;)

There's an update in the BASSMIDI download now. It adds an option (BASS_CONFIG_MIDI_VOICES) to specify the polyphony, and BASS_MIDI_StreamCreateURL and BASS_MIDI_StreamCreateFileUser functions. There is also now a VB translation of the MIDITEST example.

Mallow

  • Guest
Re: BASSMIDI beta
« Reply #9 on: 19 Oct '06 - 20:08 »
Hello :)

I may have found a bug.

When I use BASS_STREAM_DECODE flag,
it does not sound.

You can check this problem by using the following code.

Code: [Select]
#include <stdio.h>
#include <conio.h>
#include <tchar.h>
#include "bass.h"

#pragma comment(lib, "bass.lib")

#define INPUT_FILE "C:\\midi\\testmidi.mid"

static HSTREAM hData, hStr;

DWORD CALLBACK MainStreamProc(HSTREAM handle, void *buf, DWORD len, DWORD user){
    DWORD r;

    if(BASS_ChannelIsActive(hData)){
        r = BASS_ChannelGetData(hData, buf, len);
    }else{
        r = BASS_STREAMPROC_END;
    }
    return r;
}

int _tmain(int argc, _TCHAR* argv[])
{
    BASS_CHANNELINFO info;

    if(!BASS_Init(1, 44100, 0, 0, NULL)){
        printf("Can't initialize device");
        return 0;
    }

    if(!BASS_PluginLoad("bassmidi.dll", 0)){
        printf("Can't load bassmidi plugin");
        BASS_Free();
        return 0;
    }

    hData = BASS_StreamCreateFile(FALSE, INPUT_FILE, 0, 0, BASS_STREAM_DECODE | BASS_STREAM_AUTOFREE);
    if(!hData){
        printf("Can't open a file");
        BASS_Free();
        return 0;
    }

    BASS_ChannelGetInfo(hData, &info);
    hStr = BASS_StreamCreate(info.freq, info.chans, 0, &MainStreamProc, 0);
    BASS_ChannelPlay(hStr, FALSE);
    printf("Now playing...");

    while(!kbhit()){ Sleep(50);    }

    BASS_ChannelStop(hStr);
    BASS_Free();
    return 0;
}

Michael2005

  • Posts: 94
Re: BASSMIDI beta
« Reply #10 on: 20 Oct '06 - 10:29 »
I've noticed a small glitch in bass_midi.dll concerning MIDI signature (BASS_CHANNELINFO: "ctype" member). Both MIDI and AAC types have the same signature:

#define BASS_CTYPE_STREAM_AAC 0x10b00 //from "bass_aac.h"
#define BASS_CTYPE_STREAM_MIDI 0x10b00 //from "bassmidi.h"

...so basically it is impossible to distinguish between the two types based on "BASS_ChannelGetInfo(...)" calls.

radio42

  • Posts: 4574
Re: BASSMIDI beta
« Reply #11 on: 20 Oct '06 - 12:36 »
That one has already been fixed - you need to download the latest midi version from above!

So the new values for MIDI are:
BASS_CTYPE_STREAM_MIDI = 0x10d00
BASS_CONFIG_MIDI_COMPACT = 0x10400

Ian @ un4seen

  • Administrator
  • Posts: 20400
Re: BASSMIDI beta
« Reply #12 on: 20 Oct '06 - 13:02 »
When I use BASS_STREAM_DECODE flag,
it does not sound.

Oops, you're right - it wasn't initializing the default soundfont in that case. There's an update to try in the BASSMIDI download now.
« Last Edit: 20 Oct '06 - 13:04 by Ian @ un4seen »

w3k

  • Posts: 62
Re: BASSMIDI beta
« Reply #13 on: 20 Oct '06 - 13:52 »
MIDI plugin  in BASS Play MIDI no Sound :'(
« Last Edit: 20 Oct '06 - 13:57 by w3k »

Mallow

  • Guest
Re: BASSMIDI beta
« Reply #14 on: 20 Oct '06 - 15:52 »
There's an update to try in the BASSMIDI download now.

New version works fine  :)
Thanks Ian.

w3k

  • Posts: 62
Re: BASSMIDI beta
« Reply #15 on: 21 Oct '06 - 01:50 »
New version bassmidi in BASS Play MIDI no Sound  :'(
xmp-midi in xmplay Play MIDI no Sound
« Last Edit: 21 Oct '06 - 01:53 by w3k »

Ian @ un4seen

  • Administrator
  • Posts: 20400
Re: BASSMIDI beta
« Reply #16 on: 22 Oct '06 - 14:41 »
That sounds like you probably don't have a soundfont, ie. it says "no soundfont" in the Soundfont box of the MIDITEST example? Try downloading and using the Chorium soundfont in the first post.

w3k

  • Posts: 62
Re: BASSMIDI beta
« Reply #17 on: 23 Oct '06 - 02:25 »
ok BassMidi works fine 

iCorp

  • Posts: 65
Re: BASSMIDI beta
« Reply #18 on: 25 Oct '06 - 09:06 »
Yep, the BASS MIDI plugin has arrived.

Thanks, Ian.  :)

I have one questions.
As I understand BASSMIDI can't play midi without any soundfont.
Do you plan to add DLS support for using standard Windows soundfont gm.dls?
It gives possibility to play midi without downloading big soundfont file.

Thanks!

Ian @ un4seen

  • Administrator
  • Posts: 20400
Re: BASSMIDI beta
« Reply #19 on: 25 Oct '06 - 15:18 »
There are no definite plans at this time, but DLS support may happen in a future release. When first implementing the MIDI engine, the choice was whether to use SF2 or DLS soundfonts, and I found there were a lot more SF2 soundfonts available (in fact don't think I found any DLS), so that was a simple decision :)

Meanwhile... real-time events support has now been added. An update is in the BASSMIDI download, with a MIDI version of the SYNTH example also included. Please report any problems/etc...

iCorp

  • Posts: 65
Re: BASSMIDI beta
« Reply #20 on: 25 Oct '06 - 16:25 »
There are no definite plans at this time, but DLS support may happen in a future release. When first implementing the MIDI engine, the choice was whether to use SF2 or DLS soundfonts, and I found there were a lot more SF2 soundfonts available (in fact don't think I found any DLS), so that was a simple decision :)

Understand.
But everyone (almost) with Win platform have DLS soundfont on board.
When do you plan a future release?  ;)

Thanks.

emiliojazz

  • Posts: 81
Re: BASSMIDI beta
« Reply #21 on: 26 Oct '06 - 15:33 »
Hi everyone!
******************
« Last Edit: 3 Apr '07 - 01:06 by emiliojazz »

Ian @ un4seen

  • Administrator
  • Posts: 20400
Re: BASSMIDI beta
« Reply #22 on: 26 Oct '06 - 18:57 »
When do you plan a future release?  ;)

At some point later in time ;)

A simple question: does BASSMIDI use the Fluidsynth library?

Nope.

Silhwan

  • Posts: 81
Re: BASSMIDI beta
« Reply #23 on: 3 Nov '06 - 06:39 »
I am modifing TBASSPlayer to support BASSMIDI.
I have encountered following 2 problems at testing the modified TBASSPlayer with a sample MIDI file from the internet.
 1. cannot get the BASS_SYNC_DOWNLOAD event when the download process is done.
 2. cannot get the HTTP headers, i.e., BASS_ChannelGetTags(any_MIDI_handle, BASS_TAG_HTTP) returns null.   ???

Ian @ un4seen

  • Administrator
  • Posts: 20400
Re: BASSMIDI beta
« Reply #24 on: 3 Nov '06 - 16:23 »
BASSMIDI pre-downloads the entire MIDI file, and closes the file/connection before the stream creation function (eg. BASS_MIDI_StreamCreateURL) returns. So DOWNLOAD syncs and HTTP tags aren't applicable. If you want, you can still get the HTTP headers upon connection, using the BASS_STREAM_STATUS flag and a DOWNLOADPROC.

Btw, BASSMIDI wouldn't give the downloaded MIDI file to a DOWNLOADPROC... but an update that will is now in the ZIP :)