MIDISOUNDBANK: Difference between revisions

From QB64 Phoenix Edition Wiki
Jump to navigation Jump to search
(Initial version)
 
m (Add info on setting internal default sound bank)
 
(2 intermediate revisions by one other user not shown)
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 22: Line 23:
{{PageDescription}}
{{PageDescription}}
* The selected sound bank is what is used to play all MIDI files.
* The selected sound bank is what is used to play all MIDI files.
* If {{Parameter|fileName}} is an empty string ('''""'''), the sound bank will default to the internal sound bank.
* If {{Parameter|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.
* If {{Parameter|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.
* The command supports AD, OP2, OPL, SF2, SF3, SFO, TMB, WOPL formats on all supported platforms.
Line 42: Line 44:


{{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 52:
{{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}}
Line 60: Line 66:


{{PageSeeAlso}}
{{PageSeeAlso}}
* [https://qb64phoenix.com/forum/showthread.php?tid=2979 Featured in our "Keyword of the Day" series]
* [[_SNDOPEN]]
* [[_SNDOPEN]]




{{PageNavigation}}
{{PageNavigation}}

Latest revision as of 01:25, 21 November 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 an empty string (""), the sound bank will default to the internal sound bank.
  • 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