0% found this document useful (0 votes)
22 views5 pages

Creating MIDI Files Using The Classic Basic PLAY Command and MML

Uploaded by

Daniel Tkach
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views5 pages

Creating MIDI Files Using The Classic Basic PLAY Command and MML

Uploaded by

Daniel Tkach
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

5/21/24, 10:33 PM Creating MIDI files using the classic basic PLAY command and MML - freebasic.

net

  Forums   

Search…  

 Search  Login  Register

 Board index  User Contributed Sources  Sources, Examples, Tips and Tricks 

Creating MIDI files using the classic basic PLAY command and MML
Post Reply  Search this topic…   13 posts • Page 1 of 1

Creating MIDI files using the classic basic 


PLAY command and MML
 by angros47 » Jun 02, 2018 19:55

This program is a variant of the PLAY routine that, instead of playing the
angros47
notes, creates a MIDI file with the sequence. It works like the normal QBASIC
PLAY command, but it supports more than one track (using the same syntax
Posts: 2329 of GWBasic and MSX Basic, PLAY string1, string2, String3....). Notes can be
Joined: Jun 21, 2005
19:04
put between {} to play chords. The routine creates single or multitrack midi
files.
CODE: SELECT ALL
Track=_fbplay_internal (15,playstr15)
if len(Track)>0 then
Midi=Midi +"MTrk"+WriteFourBytes(len(Track)+4)+T
Tracks+=1
end if

open "output.mid" for output as #2


?#2,"MThd"+chr(0)+chr(0)+chr(0)+chr(6)+chr(0)+chr(iif(T
close
end sub

PLAY " i48 t200l4mneel2el4eel2el4egl3cl8dl1el4ffl3fl8fl4fel2el8


Re: Creating MIDI files using the classic 


basic PLAY command and MML
 by dodicat » Jun 03, 2018 10:33

I tested with various downloaded play strings (qb64 and others).


dodicat
It works really well.(Windows media player, Win 10)
For such short code and many options this is a real gem.
Posts: 7987
Joined: Jan 10, 2006
20:30
Location: Scotland 

https://www.freebasic.net/forum/viewtopic.php?t=26753 1/5
5/21/24, 10:33 PM Creating MIDI files using the classic basic PLAY command and MML - freebasic.net

  Forums Re: Creating MIDI files using the classic   



basic PLAY command and MML
 by Roland Chastain » Jun 08, 2018 21:45

Great.
Roland Chastain

Posts: 1008
Joined: Nov 24, 2011
19:49
Location: France
Contact:  

Re: Creating MIDI files using the classic


e


in
nl

basic PLAY command and MML


O

 by oyster » Jan 08, 2019 8:38

so, is there a gui?


oyster

Posts: 274
Joined: Oct 11, 2005
10:46 

Re: Creating MIDI files using the classic 


basic PLAY command and MML
 by Roland Chastain » Sep 20, 2020 12:04

Hello! Here is a humble contribution to this thread.


Roland Chastain
CODE: SELECT ALL
Posts: 1008
Joined: Nov 24, 2011
'==============================================================
' Johann Sebastian Bach
19:49
Location: France ' Sarabande from C Minor Cello Suite (BWV 1011)
' FreeBASIC version 20.09.2020
Contact: 
'==============================================================

dim as const string A = "O4 L8MLGE-<BMN>CL4<A- L8ML>>C<A-EMNFL4


dim as const string B = "O4 L8MLCE-A-MNGML>D-MNC ML<DFB-MNA-ML>
dim as const string C = "O4 L8MLB-GDMNE-L4<D- L8ML>B-GEMNFL4<G
dim as const string D = "O3 L8MLE->CFMNE-MLB-MNA ML<D>DGMNFML>CM
dim as const string E = "O5 MLE-C<F+MNGML<AMN>>E- MLL64DE-L16D.

Play("T48" & A & B & A & B & C & D & E & C & D & E & "P2 ")

https://www.freebasic.net/forum/viewtopic.php?t=26753 2/5
5/21/24, 10:33 PM Creating MIDI files using the classic basic PLAY command and MML - freebasic.net

  Forums Re: Creating MIDI files using the classic   



basic PLAY command and MML
 by Roland Chastain » May 08, 2021 12:33

Hello! I have just discovered a repository with several beautiful Bach


Roland Chastain
transcriptions :
Posts: 1008 https://github.com/vdust/beepy/tree/master/samples
Joined: Nov 24, 2011
19:49
Location: France
@angros47
Contact:  Thanks again for your program. I love it! I even converted it to Pascal. :)
Regards.
Roland 

Re: Creating MIDI files using the classic 


basic PLAY command and MML
 by angros47 » May 08, 2021 15:23

You are welcome!


angros47
In case you are interested in a newer version, I included the code of this
Posts: 2329 program in SFX library:
Joined: Jun 21, 2005
19:04
https://sourceforge.net/projects/freebasic-sfx-library/ 

Re: Creating MIDI files using the classic 


basic PLAY command and MML
 by Roland Chastain » May 08, 2021 17:31

 angros47 wrote:
Roland Chastain
In case you are interested in a newer version, I included the code of this
Posts: 1008 program in SFX library:
Joined: Nov 24, 2011 https://sourceforge.net/projects/freebasic-sfx-library/
19:49
Location: France I already have the SFX library in my FB directory, but hadn't noticed until now
Contact:  that it includes a new version of playtomidi. (When I downloaded it, I had
something else in mind.)
I will take a look to the new version.
By the way, what do you think about the abc format? 

https://www.freebasic.net/forum/viewtopic.php?t=26753 3/5
5/21/24, 10:33 PM Creating MIDI files using the classic basic PLAY command and MML - freebasic.net

  Forums Re: Creating MIDI files using the classic   



basic PLAY command and MML
 by angros47 » May 08, 2021 17:48

The SFX library (likely the one you have already downloaded) allows you to
angros47
use the PLAY command both to play midi notes directly (like in QBasic and
QB64), or to create a midi file.
Posts: 2329
Joined: Jun 21, 2005
19:04
To create a midi file, you should do something like:
CODE: SELECT ALL

dim buffer as any ptr


buffer=CreateMidi()
play buffer, "cdefgab"
SaveMidi ("file.midi", buffer)

Personally, I am Italian, and here we use the do-re-mi notation 

Re: Creating MIDI files using the classic 


basic PLAY command and MML
 by Roland Chastain » May 08, 2021 20:02

Thank you for the code example.


Roland Chastain
 angros47 wrote:
Posts: 1008 Personally, I am Italian, and here we use the do-re-mi notation
Joined: Nov 24, 2011
19:49 Sorry, my question was not clear. I was speaking of this. I was wondering
Location: France what is better to learn, MML or abc. It seems that there are more tools and
Contact:  resources available for the abc format. 

Re: Creating MIDI files using the classic 


basic PLAY command and MML
 by angros47 » May 08, 2021 20:51

MML is not an alternative to ABC notation. It stands for "Music Macro


angros47
Language", a format that uses ABC notation.
Posts: 2329 Notation can be in ABC format, or in the do-re-mi format (C=do, D=re,
Joined: Jun 21, 2005
19:04
E=mi, F=fa, G=sol, A=la, b=si). The original notation was in the do-re-mi
format, then the ABC format has been adopted because it was faster to write
The MML is a simple language, used originally in the older BASIC interpreters
(including MSX basic, BASICA and GwBasic), that uses the ABC notation.
Basically, the abc notation can be compared to the alphabet, and the MML
can be compared to the language. So, your questions sounds a bit like "What
is better to learn, the Latin alphabet or the English language?". To be able to
write in English you need to know both 

https://www.freebasic.net/forum/viewtopic.php?t=26753 4/5
5/21/24, 10:33 PM Creating MIDI files using the classic basic PLAY command and MML - freebasic.net

  Forums Re: Creating MIDI files using the classic   



basic PLAY command and MML
 by Roland Chastain » Aug 01, 2022 19:48

Hello!
Roland Chastain
I created a git repository for my Pascal version, with a lot of music examples
Posts: 1008 that I found here and there.
Joined: Nov 24, 2011
19:49
Location: France
Regards.
Contact: 
Roland 

Re: Creating MIDI files using the classic 


basic PLAY command and MML
 by grymmjack » Jan 10, 2023 2:07

 angros47 wrote: ↑ Jun 02, 2018 19:55


grymmjack
This program is a variant of the PLAY routine that, instead of playing the
Posts: 3 notes, creates a MIDI file with the sequence.
Joined: Jan 10, 2023
1:23 This is a great idea! I post this to say thanks. I have not tried it, but I will.
Location: MI, USA
Contact:  Really cool! 

Post Reply    13 posts • Page 1 of 1

 Return to “Sources, Examples, Tips and Tricks” Jump to 

 Board index  Contact us  Delete cookies All times are UTC

Powered by phpBB® Forum Software © phpBB Limited


Style by Arty
Privacy | Terms

https://www.freebasic.net/forum/viewtopic.php?t=26753 5/5

You might also like