Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 06:55 02 Aug 2025 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : Sound in dos mmbasic

Author Message
busa
Regular Member

Joined: 12/02/2015
Location: Australia
Posts: 81
Posted: 12:05am 29 Sep 2019
Copy link to clipboard 
Print this post

Hi all,
Is it possible to play a sound file from within DOS MMBasic ver 5.05.01
I have searched the forum and the manual but no luck with either.
Regards
busa
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6283
Posted: 03:04am 29 Sep 2019
Copy link to clipboard 
Print this post

You can use the SYSTEM command to do anything in DOS

  Quote    ' sounds in DOS
 FOR n = 1 TO 5
   
SYSTEM "echo "+CHR$(7)
   
' that gets the default beep
   PAUSE 1000
 
NEXT n
 


You need to use a suitable player to play WAV or MP3 files but if you want the create your own sounds on the fly it's a bit harder.

Jim
VK7JH
MMedit
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6283
Posted: 05:52am 29 Sep 2019
Copy link to clipboard 
Print this post

This might help.
It only plays WAV files, not MP3

Put the exe file in the same folder as your MMbasic file or include the full path to the exe.

  Quote    ' sounds in DOS
 FOR n = 1 TO 3
   
SYSTEM "echo "+CHR$(7)
   
' that gets the default beep
   PAUSE 1000
 
NEXT n
 
' MMextra.exe play tone left, right , duration (Right channel ignored)
 ' MMextra.exe play tone left , duration
 ' MMextra.exe play wav "path t0 WAV file"
 SYSTEM "MMextra.exe play tone 800, 300 , 1000" ' second channel ignored
 SYSTEM "MMextra.exe play tone 440 ,2000"
 
SYSTEM "MMextra.exe play wav "+CHR$(34)+"C:\Windows\Media\ringout.wav"+CHR$(34)
 


I tried to emulate the MMbasic PLAY command.

MMextra.zip

Jim
VK7JH
MMedit
 
busa
Regular Member

Joined: 12/02/2015
Location: Australia
Posts: 81
Posted: 10:35am 29 Sep 2019
Copy link to clipboard 
Print this post

Thanks Jim, don't know how you did that but it seems to work well. Will play around with it some more tonight.  
 
Quazee137

Guru

Joined: 07/08/2016
Location: United States
Posts: 593
Posted: 10:00pm 29 Sep 2019
Copy link to clipboard 
Print this post

Does W10 have the CLI play? MS has added a lot of LINUX functionality in the last
few years.

open CMD and try "play -h". If its there you can use most sound files even music.
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6283
Posted: 10:16pm 29 Sep 2019
Copy link to clipboard 
Print this post

  Quazee137 said  Does W10 have the CLI play? MS has added a lot of LINUX functionality in the last
few years.

open CMD and try "play -h". If its there you can use most sound files even music.

No - no play in W10. There might be something in powershell. I don't like powershell.
Win XP and earlier did have a simple to use command line sound program but MS decided we didn't need it any more.

Ubuntu on Windows doesn't either but could be added I assume. I haven't played with audio in that configuration.

The program MMextra has the ability to play 'sounds' not just WAV files so is closer to MMBasic.
I will add stereo and few sound effects sometime.

Jim
VK7JH
MMedit
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6283
Posted: 08:04am 30 Sep 2019
Copy link to clipboard 
Print this post

I have been playing again.

Sounds are now in stereo and there are a few different sound effects.

  Quote    ' sounds in DOS
 ' Place MMextra.exe either with MMBasic.exe or your BAS file depending on how you start the program.
 ' you can also specify the full path to MMextra.exe
 ' MMextra.exe play tone left, right , duration
 ' MMextra.exe play effect left, right , duration, amplitude, sweepStop, waveform, FadeIn, FadeOut
 ' left, right in Hz
 ' duration in mS
 ' amplitude 0 to 100
 ' sweepstop max frequency in Hz. Mono - uses left channel only
 ' waveform:
 ' SineWave = 1
 ' SawTooth = 2
 ' BuzzSaw = 3
 ' SquareWave = 4
 ' Triangle = 5
 ' Chunosta = 6
 ' Organ = 7
 ' Noise = 8
 ' GuidedNoise = 9
 ' FadeIn, FadOut 1 for yes, 0 for no
 
 
' MMextra.exe play wav "path to WAV file" quotes need around filename if it contains spaces
 
 
SYSTEM "MMextra.exe play tone 700, 1900, 3000" ' twotone test
 SYSTEM "MMextra.exe play effect 440 ,,2000,25,0,1,0,0" ' sinewave
 SYSTEM "MMextra.exe play effect 440 ,,2000,25,0,7,0,1" ' organ fading out
 SYSTEM "MMextra.exe play effect 440 ,,2000,25,1500,7,0,0" ' sweep
 PAUSE 1000
 
SYSTEM "MMextra.exe play wav "+CHR$(34)+"C:\Windows\Media\ringout.wav"+CHR$(34)
 


Hopefully self explanatory

The programs first generates the waveform and then plays it. This means that continuous play is not an option. Nor is changing frequency on the fly like micromites can.

It also means that if you specify a long duration, there will be a noticeable delay before the sound starts playing.

MMextra.zip

The sound generating routines I used were coded by BasicallyPure on the PureBasic forum.
I tweaked it into stereo.

Jim
VK7JH
MMedit
 
busa
Regular Member

Joined: 12/02/2015
Location: Australia
Posts: 81
Posted: 11:39am 30 Sep 2019
Copy link to clipboard 
Print this post

Thanks again Jim, that's better than I had hoped for.
It's going to keep me busy while I play (pun intended) around with it.  
 
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025