Jump to content


 


Register a free account to unlock additional features at BleepingComputer.com
Welcome to BleepingComputer, a free community where people like yourself come together to discuss and learn how to use their computers. Using the site is easy and fun. As a guest, you can browse and view the various discussions in the forums, but can not create a new topic or reply to an existing one unless you are logged in. Other benefits of registering an account are subscribing to topics and forums, creating a blog, and having no ads shown anywhere on the site.


Click here to Register a free account now! or read our Welcome Guide to learn how to use this site.

Photo

Audio command


  • Please log in to reply
3 replies to this topic

#1 Barnack

Barnack

  • Members
  • 91 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Italy
  • Local time:07:44 AM

Posted 27 August 2014 - 07:00 AM

I'd like to know if exists, or if is possible to create it (i'm not an expert programmer, so i don't know if that would take much or little time) a symple command to start reproducing mp3 or midi files. Not a program that opens a screen, like dosamp, but a simple string.

Like that:

play x.mp3; y.mp3; z.mp3 /L3 /S2
play x.mp3 /L0 /S0.5
or
play x.mpr /a
play /showlist /p
play /end

play x.mp3 = plays the musicfile
play x.mp3; y.mp3; z.mp3 = plays the musicfiles in order
/L0 = reproduces every track listed looped. Obviously with a list only the first track is riproduced
/Lx = reproduces every track listed x times before go to the next one
/Sx = changes play speed (it's a multiplyer /s2=2x, /s0.5=1/2x)
play x.mp3 /a = adds the track to the list. if /Lx or/and /Sx are specifyed, they only apply to that track, not to the others of list
play /showlist /p = shows a list of files in a gird: (/p is optional, means in pages as "dir /p")

name, loop(actual/total), speed
asdfdf.mp3 3/5 2x
aggfs.mp3 0/1 1x

play /end =instantly stops the music and clears the list

Oh, and music should continue playing while using DOS obviously.

I'd like to use that, for example, to start a looped theme in the autoexec.bat, and to stop it when you go to command prompt (so when you passed over the multiple choice menu, if i succesfully complete it.

 

Oh, it's FreeDOS ambient, not MS-DOS, i know that there are some differences


Edited by Barnack, 27 August 2014 - 07:02 AM.


BC AdBot (Login to Remove)

 


#2 JohnnyJammer

JohnnyJammer

  • Members
  • 1,117 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:QLD Australia
  • Local time:03:44 PM

Posted 27 August 2014 - 07:25 PM

I did a Ruby script years ago which does this and can be altered to suit your needs if need be.

Install ruby and then opena  dos prompt and drag the Ruby Script into the Dos promopt and hit enter.

Then select the music and hit enter.

 

Script below

require "win32ole" 
require 'find'
song = WIN32OLE.new("MCI.MMcontrol") 
voice = WIN32OLE.new("SAPI.SpVoice")
dialogbox = WIN32OLE.new("MSComDlg.CommonDialog") 
seconds = 0
minutes = 0 
mins = 0
secs = 0.0
def openfile(dialog)
  #system "cls"
  begin
  sleep 1 # sets the delay
    dialog.DialogTitle = "Choose a File" 
    dialog.Filter = "MP3 Files | *.mp3" 
    dialog.FilterIndex = 2
    dialog.MaxFileSize = 1024   
    #dialog.AboutBox 
    dialog.showOpen()
        txtfile = dialog.FileName      
    if not txtfile or txtfile == "" 
        puts "\nNo filename entered."
        #exit!
    else
        puts "\nYou selected: #{txtfile}\n"
        #sleep 4
            return(txtfile)
    end
  rescue StandardError=> error_msg # error handler
      puts "#{error_msg}" # display error message back to console
  end
end
begin
system 'cls'
puts "
|-          The Ruby Jute Box        -|
|-          By John G               -|
---------------------------------------\n\n"
puts "Curent working directory is:\nDir= #{Dir.getwd}"
#Find.match(Dir.getwd) { |p| File.split(p)[0] == "." }
puts "Drag the song into the DOS prompt & press ENter to start:"
track = openfile(dialogbox)
track.gsub!(/\"/, "") # strip the quotation from the directory string
song.fileName = track
puts "Now Playing: #{track}"
system "title #{track}"
#song.AboutBox # display the Active X version
song.command = "Open" 
song.command = "Play" 
datalen = song.Length / 1024 - 1
puts song.Length
puts song.TimeFormat
#puts "Frames = #{song.Frames}"
puts "Song Length is #{datalen} Seconds."
mins = (datalen / 60)
secs = datalen - (mins * 60)
puts "Song goes for #{mins.to_i} minutes:#{secs.to_i}"
#playlen = (datalen / 60) % datalen
for x in (0..datalen) do
    if seconds > 60 then
        minutes = minutes + 1
        seconds = 0            
    else
        system "title Playing: #{track} - #{minutes}.#{seconds}"
        seconds = seconds + 1
        print "\rPlaytime:#{x}"
        #voice.Speak x
        sleep 1 # pause for 1 second intervals
    end
end
#sleep song.Length
rescue StandardError => error_msg
puts "Error has ocoured:#{error_msg}"
if song.Length then puts "Done playing the Music" end
song.command = "close"
end

Ill see if i can get a batch file script to minmic the same thing.


Edited by JohnnyJammer, 27 August 2014 - 07:27 PM.


#3 Barnack

Barnack
  • Topic Starter

  • Members
  • 91 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Italy
  • Local time:07:44 AM

Posted 28 August 2014 - 04:27 AM

"Ill see if i can get a batch file script to minmic the same thing." If you can i'd be very very grateful

But more than a batch i what i need is a .cmd or .exe.

The idea is, for example, putting in autoexec.bat the string "play theme.mp /L0", so for all the time i use dos, that theme would be a background theme (till i stop it). A batch file alone cannot play music without the relative command, and that's what i need.

Personally i was hoping something already existed...

Btw, ruby can be installed in DOS? I found installers for every platform but not for dos... You wrote "command prompt", i hope u don't think i'm using Windows "CMD"; i'm using a bootable usb device with freedos installed


Edited by Barnack, 28 August 2014 - 04:28 AM.


#4 JohnnyJammer

JohnnyJammer

  • Members
  • 1,117 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:QLD Australia
  • Local time:03:44 PM

Posted 28 August 2014 - 06:22 PM

Yeah sorry, i thought you where talking about windows dos prompt, now as far as Dos %OS% i doubt you could play a file in the back ground.






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users