•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the Ruby section within the Web Development category of DaniWeb, a massive community of 332,772 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,876 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Ruby advertiser: SELL YOUR PRODUCT TODAY !
Using an SDL (Simple DirectMedia Layer) wrapper is one way to play sound and music with Ruby. I have tested this snippet with .MID .MOD and .WAV files and it performs well. There are several SDL wrappers for Ruby available, I picked RUDL because of its simplicity. RUDL is great for writing games.
# play a midi file or mod file using the SDL wrapper for Ruby # download RUDL from: http://sourceforge.net/projects/rudl/ # file: rudl-0.8-for-ruby-1.8.2-setup-releasebuild.zip # includes the needed SDL .dll files # run install-on-windows.rb and follow instructions # tested with Ruby182 and Windows XP vegaseat 17mar2006 (yeah Irish!) require "RUDL" # this gets rid of the namespace include RUDL # pick a midi file you have in the workfolder # or add the full path to the filename filename = "TeaFor2.mid" music = Music.new(filename) music.play # needed to play music to the end gets
Post Comment
•
•
•
•
DaniWeb Marketplace (Sponsored Links)