Author Topic: MIDI File Support  (Read 3470 times)

vidiware

  • Posts: 6
MIDI File Support
« on: 16 May '03 - 05:44 »
Is there some kind of midi support in there?
if not then its a suggestion from me to add...
And how do you use the midi

Sebastian_Mares

  • Guest
Re: MIDI File Support
« Reply #1 on: 16 May '03 - 06:48 »
At the moment, BASS does not offer any support for MIDI files. You can play them using ordinary mciSendString API. The only thing you might miss when doing so is the spectrum analyzer and specific BASS functions. Setting the position, increasing the volume, pausing... are also able with the system-intern commands.

Sebastian_Mares

  • Guest
Re: MIDI File Support
« Reply #2 on: 16 May '03 - 06:50 »
A Visual Basic example from API-Guide:

Code: [Select]

'This project needs a Common Dialog box, named 'CDBox'
'  (To add the Common Dialog Box to your tools menu, go to Project->Components (or press CTRL-T)
'   and select Microsoft Common Dialog control)
Private Declare Function mciSendString Lib "winmm.dll" Alias "mciSendStringA" (ByVal lpstrCommand As String, ByVal lpstrReturnString As String, ByVal uReturnLength As Long, ByVal hwndCallback As Long) As Long
Dim Alias As String
Private Sub Form_Load()
   'KPD-Team 1998
   'URL: http://www.allapi.net/
   'E-Mail: KPDTeam@Allapi.net
   Const PlayTime = 10
   'Set the common dialog box' title
   CDBox.DialogTitle = "Choose your midi-file"
   'Set the filter
   CDBox.Filter = "Midi-files (*.mid)|*.mid"
   'Show the 'Open File'-dialog
   CDBox.ShowOpen
   'Extract an alias from the file
   Alias = Left$(CDBox.FileTitle, Len(CDBox.FileTitle) - 4)

   'play midi
   R% = mciSendString("OPEN " + CDBox.filename + " TYPE SEQUENCER ALIAS " + Alias, 0&, 0, 0)
   R% = mciSendString("PLAY " + Alias + " FROM 0", 0&, 0, 0)
   R% = mciSendString("CLOSE ANIMATION", 0&, 0, 0)

   'play midi for 10 secs
   t = Timer
   Do: DoEvents: Loop Until Timer > t + PlayTime

   'stop midi and close it
   R% = mciSendString("OPEN " + CDBox.filename + " TYPE SEQUENCER ALIAS " + Alias, 0&, 0, 0)
   R% = mciSendString&("STOP " + Alias, 0&, 0, 0)
   R% = mciSendString&("CLOSE ANIMATION", 0&, 0, 0)
End Sub