Recent

Author Topic: QBasic-style music to MIDI file  (Read 565 times)

Roland57

  • Sr. Member
  • ****
  • Posts: 310
QBasic-style music to MIDI file
« on: August 02, 2022, 07:33:15 pm »
Hello!

Here is a little tool which creates a MIDI file from a QBasic-style string for the Play command. It's a literal translation of a FreeBASIC program.

Example:
Code: Pascal  [Select][+][-]
  1. (* sarabande.pas *)
  2.  
  3. uses
  4.   SysUtils, Play2Mid;
  5.  
  6. (*
  7. ========================================================================
  8.  Johann Sebastian Bach
  9.  Sarabande from C Minor Cello Suite (BWV 1011)
  10.  FreeBASIC version 20.09.2020
  11. ========================================================================
  12. *)
  13.  
  14. const
  15.   A = 'O4 L8MLGE-<BMN>CL4<A- L8ML>>C<A-EMNFL4<B L8ML>>D<A-EMNFML<GMN>G MLFE-<BMN>CL4<C';
  16.   B = 'O4 L8MLCE-A-MNGML>D-MNC ML<DFB-MNA-ML>CMN<B- MLA-GDMNE-ML<B-MN>D L2ML<E-.';
  17.   C = 'O4 L8MLB-GDMNE-L4<D- L8ML>B-GEMNFL4<G L8ML>>D-<B-EMNFML<CMN>>C ML<B-A-EMNFL4<F';
  18.   D = 'O3 L8MLE->CFMNE-MLB-MNA ML<D>DGMNFML>CMN<B ML>C<A-F+MNGML<BMN>C ML<G>DGMNF+ML>CMN<B';
  19.   E = 'O5 MLE-C<F+MNGML<AMN>>E- MLL64DE-L16D.L8<A-EMNFML<BMN>G MLFE-<BMN>CML<GMN>B ML<CG>FMNE-L4ML>C';
  20.  
  21. begin
  22.   midiFileName := 'sarabande.mid';
  23.   Play('T48' + A + B + A + B + C + D + E + C + D + E + 'P2.');
  24. end.
  25.  

QBasic music to MIDI file
« Last Edit: August 02, 2022, 08:47:07 pm by Roland57 »

Mastropiero

  • New Member
  • *
  • Posts: 19
Re: QBasic-style music to MIDI file
« Reply #1 on: August 23, 2022, 04:21:30 pm »
Excellent.

I used to make great tunes with this language (not only used on Qbasic, it is the most popular way to create music on 8bit/16bit computers in Japan during the 80s and early 90s).  Most Sega Mastersystem and Genesis musics were composed by using this kind strings. They are commonly known as MML (Macro Music Language) and you can still find tons of emulators and tools to compose and listen to music written in this way.

More info here: http://www.vgmpf.com/Wiki/index.php/Music_Macro_Language

It would be very nice to have not only the MML parser, but a whole sound engine for it written in Freepascal. Most common chips used for this kind of music were AY-3-8910, YM2203, YM2151, YM2608...  What about emulating those chips? There already are tons of implementations in C or C++ so they could be easily translated to Pascal.

shyub

  • Jr. Member
  • **
  • Posts: 96
Re: QBasic-style music to MIDI file
« Reply #2 on: August 24, 2022, 11:04:55 am »
For some reason, the execution of the procedure "Play('T48'....);" gives me an error.

Roland57

  • Sr. Member
  • ****
  • Posts: 310
Re: QBasic-style music to MIDI file
« Reply #3 on: August 24, 2022, 01:03:25 pm »
I used to make great tunes with this language (not only used on Qbasic, it is the most popular way to create music on 8bit/16bit computers in Japan during the 80s and early 90s).  Most Sega Mastersystem and Genesis musics were composed by using this kind strings. They are commonly known as MML (Macro Music Language) and you can still find tons of emulators and tools to compose and listen to music written in this way.

Thank you for the informations.

Roland57

  • Sr. Member
  • ****
  • Posts: 310
Re: QBasic-style music to MIDI file
« Reply #4 on: August 24, 2022, 01:03:44 pm »
For some reason, the execution of the procedure "Play('T48'....);" gives me an error.

Which error please?

 

TinyPortal © 2005-2018