MIDISOUNDBANK: Difference between revisions

From QB64 Phoenix Edition Wiki
Jump to navigation Jump to search
(Initial version)
 
No edit summary
Line 1: Line 1:
{{DISPLAYTITLE:_MIDISOUNDBANK}}
The '''_MIDISOUNDBANK''' command enables [[_SNDOPEN]] to use an external FM Bank or SoundFont when playing MIDI files.
The '''_MIDISOUNDBANK''' command enables [[_SNDOPEN]] to use an external FM Bank or SoundFont when playing MIDI files.


Line 42: Line 43:


{{PageExamples}}
{{PageExamples}}
;Example 1:Loading a MIDI sound bank and play a song.
{{CodeStart}}
{{CodeStart}}
{{Cl|_MIDISOUNDBANK}} {{Text|<nowiki>"awesome.sf3"</nowiki>|#FFB100}}
{{Cl|_MIDISOUNDBANK}} {{Text|<nowiki>"awesome.sf3"</nowiki>|#FFB100}}
Line 49: Line 51:
{{CodeEnd}}
{{CodeEnd}}


----
;Example 2:Instead of loading a MIDI sound bank, it can also be embedded and used with the MEMORY capabilitiy.
{{CodeStart}}
{{CodeStart}}
{{Cm|$EMBED}}:{{Text|<nowiki>'./tiny.sf2','mysf2'</nowiki>|#919191}}
{{Cm|$EMBED}}:{{Text|<nowiki>'./tiny.sf2','mysf2'</nowiki>|#919191}}

Revision as of 14:33, 23 July 2024

The _MIDISOUNDBANK command enables _SNDOPEN to use an external FM Bank or SoundFont when playing MIDI files.


Syntax

_MIDISOUNDBANK: fileName$[, capabilities$]


Parameters

  • fileName is literal or variable STRING file name value.
  • The literal or variable STRING capabilities$ is optional, but it can be set to MEMORY and one of the following formats:
    • MEMORY: This will treat fileName as a memory buffer containing the sound file instead of a file name.
    • AD: Global Timbre Library format for Audio Interface Library.
    • OP2: DMX OPL-2 format.
    • OPL: Global Timbre Library format for Audio Interface Library.
    • SF2: Creative's SoundFont 2.0 format.
    • SF3: MuseScore's Ogg compressed Creative SoundFont 2.0 format.
    • SFO: Bernhard Schelling's Ogg compressed Creative SoundFont 2.0 format.
    • TMB: Apogee Sound System timbre format.
    • WOPL: Vitaly Novichkov's OPL3BankEditor format.


Description

  • The selected sound bank is what is used to play all MIDI files.
  • If fileName is missing, corrupted, or inaccessible, the command will not produce any errors. However, subsequent attempts to open a MIDI file with _SNDOPEN will fail.
  • The command supports AD, OP2, OPL, SF2, SF3, SFO, TMB, WOPL formats on all supported platforms.
  • It also supports VSTi (Virtual Studio Technology Instruments) 2.x (DLL) on Windows. However, a VST host, such as the one utilized by foo_midi, is required.
  • _EMBEDDED$ sound banks can be used directly with _MIDISOUNDBANK.


Availability


Examples

Example 1
Loading a MIDI sound bank and play a song.
_MIDISOUNDBANK "awesome.sf3"

handle = _SNDOPEN("onestop.mid")
_SNDPLAY handle

Example 2
Instead of loading a MIDI sound bank, it can also be embedded and used with the MEMORY capabilitiy.
$EMBED:'./tiny.sf2','mysf2'

_MIDISOUNDBANK _EMBEDDED$("mysf2"), "memory, sf2"

handle = _SNDOPEN("canyon.xmi")
_SNDPLAY handle


See also



Navigation:
Main Page with Articles and Tutorials
Keyword Reference - Alphabetical
Keyword Reference - By usage
Report a broken link