Ruby sdl, audio playback

I need some help working with sdl. At this point all I'm trying to do is
get ruby to play an audio file using the rubysdl gem (I really can't find
much out there on this gem except for the documentation). this is my code
as of right now:
  #!/usr/bin/ruby

require 'sdl'

SDL.init(SDL::INIT_AUDIO)
sound = SDL::Mixer.open(44100, SDL::Mixer::DEFAULT_FORMAT, 2, 1024)
sound.load("rebel-theme.wav")

but when I try to run it I get:
  sdlaudio.rb:7:in `<main>': private method `load' called for nil:NilClass
(NoMethodError)

I'm still pretty new to ruby and I may be in over my head here but I've
found that at least for me thats the best way to learn (once I actually
start to catch on which as far as sdl is concerned, I have not, lol).
My goal with this app is to make a simple audio player, but down the road
my larger goal is to work with audio synthesis. I'm assuming the sdl gem is
where I want to be for those goals but I may be wrong there too. So I guess
my next question is, am I on the right track diving into 'rubysdl' or is
there another avenue I should be exploring?

The error message is telling you that the load method does not exist in the sound class/object. Sounds as if you need better documentation on SDL.

···

On 17/11/2016 10:20 PM, Micky Scandal wrote:

I need some help working with sdl. At this point all I'm trying to do is get ruby to play an audio file using the rubysdl gem (I really can't find much out there on this gem except for the documentation). this is my code as of right now:
  #!/usr/bin/ruby

require 'sdl'

SDL.init(SDL::INIT_AUDIO)
sound = SDL::Mixer.open(44100, SDL::Mixer::DEFAULT_FORMAT, 2, 1024)
sound.load("rebel-theme.wav")

but when I try to run it I get:
  sdlaudio.rb:7:in `<main>': private method `load' called for nil:NilClass (NoMethodError)

I'm still pretty new to ruby and I may be in over my head here but I've found that at least for me thats the best way to learn (once I actually start to catch on which as far as sdl is concerned, I have not, lol).
My goal with this app is to make a simple audio player, but down the road my larger goal is to work with audio synthesis. I'm assuming the sdl gem is where I want to be for those goals but I may be wrong there too. So I guess my next question is, am I on the right track diving into 'rubysdl' or is there another avenue I should be exploring?

Unsubscribe: <mailto:ruby-talk-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk&gt;

No virus found in this message.
Checked by AVG - www.avg.com <http://www.avg.com>
Version: 2016.0.7859 / Virus Database: 4664/13428 - Release Date: 11/17/16

--
Patrick Bayford Tel : 020 8265 8376 E-mail : pbayford@talktalk.net

I don't have any working examples for this, but my graphics gem has sdl-mixer already hooked up. You can either pilfer from it or feel free to switch to it. I'm actively working on it (not the audio part, yet, but I'm totally happy to take a PR with an example using it).

···

On Nov 17, 2016, at 14:20, Micky Scandal <mickyscandal@gmail.com> wrote:

I need some help working with sdl. At this point all I'm trying to do is get ruby to play an audio file using the rubysdl gem (I really can't find much out there on this gem except for the documentation). this is my code as of right now:
  #!/usr/bin/ruby

require 'sdl'

SDL.init(SDL::INIT_AUDIO)
sound = SDL::Mixer.open(44100, SDL::Mixer::DEFAULT_FORMAT, 2, 1024)
sound.load("rebel-theme.wav")

The SDL documentation seems to suggest that you have to install SDL mixer, and some additional background modules - are you sure you have these in place?
SDL doc :-
http://www.libsdl.org/projects/SDL_mixer/

···

On 17/11/2016 11:29 PM, Patrick Bayford wrote:

On 17/11/2016 10:20 PM, Micky Scandal wrote:

I need some help working with sdl. At this point all I'm trying to do is get ruby to play an audio file using the rubysdl gem (I really can't find much out there on this gem except for the documentation). this is my code as of right now:
  #!/usr/bin/ruby

require 'sdl'

SDL.init(SDL::INIT_AUDIO)
sound = SDL::Mixer.open(44100, SDL::Mixer::DEFAULT_FORMAT, 2, 1024)
sound.load("rebel-theme.wav")

but when I try to run it I get:
  sdlaudio.rb:7:in `<main>': private method `load' called for nil:NilClass (NoMethodError)

I'm still pretty new to ruby and I may be in over my head here but I've found that at least for me thats the best way to learn (once I actually start to catch on which as far as sdl is concerned, I have not, lol).
My goal with this app is to make a simple audio player, but down the road my larger goal is to work with audio synthesis. I'm assuming the sdl gem is where I want to be for those goals but I may be wrong there too. So I guess my next question is, am I on the right track diving into 'rubysdl' or is there another avenue I should be exploring?

Unsubscribe:<mailto:ruby-talk-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk&gt;

No virus found in this message.
Checked by AVG - www.avg.com <http://www.avg.com>
Version: 2016.0.7859 / Virus Database: 4664/13428 - Release Date: 11/17/16

The error message is telling you that the load method does not exist in the sound class/object. Sounds as if you need better documentation on SDL.

--
Patrick Bayford Tel : 020 8265 8376 E-mail : pbayford@talktalk.net

Unsubscribe: <mailto:ruby-talk-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk&gt;

No virus found in this message.
Checked by AVG - www.avg.com <http://www.avg.com>
Version: 2016.0.7859 / Virus Database: 4664/13428 - Release Date: 11/17/16

--
Patrick Bayford Tel : 020 8265 8376 E-mail : pbayford@talktalk.net

I'll definitaly take a look at your gem, what's it called? I noticed
someone else mentioned having to install SDL_Mixer But I do already have it
installed so I'm pretty sure that's not the issue (not sure why that reply
ended up in my spam folder...). right now, I'm looking at other gems that
are more suited to directly what i need like ruby-audio, or easy_audio
(which both use sdl, i think), so there's less extra stuff I don't need.
does anyone know of a gem i havent mentioned for playing/working with audio
files? or if anyone just has some general advice on working with sound, i
would really appriciate it. I know I'm in over my head, but I figure it's
sink or swim and I'm too fat to sink!

···

On Fri, Nov 18, 2016 at 2:27 PM, Ryan Davis <ryand@zenspider.com> wrote:

> On Nov 17, 2016, at 14:20, Micky Scandal <mickyscandal@gmail.com> wrote:
>
> I need some help working with sdl. At this point all I'm trying to do is
get ruby to play an audio file using the rubysdl gem (I really can't find
much out there on this gem except for the documentation). this is my code
as of right now:
> #!/usr/bin/ruby
>
> require 'sdl'
>
> SDL.init(SDL::INIT_AUDIO)
> sound = SDL::Mixer.open(44100, SDL::Mixer::DEFAULT_FORMAT, 2, 1024)
> sound.load("rebel-theme.wav")

I don't have any working examples for this, but my graphics gem has
sdl-mixer already hooked up. You can either pilfer from it or feel free to
switch to it. I'm actively working on it (not the audio part, yet, but I'm
totally happy to take a PR with an example using it).

Unsubscribe: <mailto:ruby-talk-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk&gt;

the gem name IS 'graphics'

···

On Nov 18, 2016, at 16:42, Micky Scandal <mickyscandal@gmail.com> wrote:

I'll definitaly take a look at your gem, what's it called? I noticed someone else mentioned having to install SDL_Mixer But I do already have it installed so I'm pretty sure that's not the issue (not sure why that reply ended up in my spam folder...). right now, I'm looking at other gems that are more suited to directly what i need like ruby-audio, or easy_audio (which both use sdl, i think), so there's less extra stuff I don't need. does anyone know of a gem i havent mentioned for playing/working with audio files? or if anyone just has some general advice on working with sound, i would really appriciate it. I know I'm in over my head, but I figure it's sink or swim and I'm too fat to sink!