Playing raw PCM files in ruby

Hello everyone,

I am trying to play the music from the old game “Ascendancy” using
Ruby, the files are 8-bit unsigned raw PCM files at 22 khz. I thought
about using SDL for playing them, but I can’t seem to find any way to
load these files with the ruby bindings. Has anyone done this before
or has any other idea how to play the sound?

On 8/29/2010 2:45 PM, Roger B. wrote:

Hello everyone,

I am trying to play the music from the old game “Ascendancy” using
Ruby, the files are 8-bit unsigned raw PCM files at 22 khz. I thought
about using SDL for playing them, but I can’t seem to find any way to
load these files with the ruby bindings. Has anyone done this before
or has any other idea how to play the sound?

You might be better off converting these sounds to something that can be
handled more easily. You could use a command-line tool like Sox to do
the job, just iterate over the files (in Ruby, perhaps) and convert them
to wav files. This has the added benefit of possibly encoding them in
MP3 or Ogg Vorbis for smaller file sizes.

Raw PCM should be able to be handled though. The problem is, raw PCM
has no header information. If you know the exact format, you could
theoretically load it into memory and have it played, but it’ll be a
pain. If you get any of the settings wrong, you might as well be
pumping random noise through your speakers.

On Sun, Aug 29, 2010 at 8:58 PM, Michael M. [email protected]
wrote:

You might be better off converting these sounds to something that can be
handled more easily. You could use a command-line tool like Sox to do the
job, just iterate over the files (in Ruby, perhaps) and convert them to wav
files. This has the added benefit of possibly encoding them in MP3 or Ogg
Vorbis for smaller file sizes.

Thanks for the suggestion, but I would really like to play the files
directly from the games archive format.

Raw PCM should be able to be handled though. The problem is, raw PCM has no
header information. If you know the exact format, you could theoretically
load it into memory and have it played, but it’ll be a pain. If you get any
of the settings wrong, you might as well be pumping random noise through
your speakers.

That’s exactly what I want to do, but I found no way to actually do
this. Wrong settings are no problem here, because all the music files
in the game use the same format and the program is just supposed to
play these songs.

Roger B. wrote:

Hello everyone,

I am trying to play the music from the old game “Ascendancy” using
Ruby, the files are 8-bit unsigned raw PCM files at 22 khz. I thought
about using SDL for playing them, but I can’t seem to find any way to
load these files with the ruby bindings. Has anyone done this before
or has any other idea how to play the sound?

Linux or windows?
-r

On Mon, Aug 30, 2010 at 7:37 PM, Roger P. [email protected]
wrote:

Linux or windows?

Possibly both. But mainly Linux.

On Aug 29, 1:45 pm, Roger B. [email protected]
wrote:

Hello everyone,

I am trying to play the music from the old game “Ascendancy” using
Ruby, the files are 8-bit unsigned raw PCM files at 22 khz. I thought
about using SDL for playing them, but I can’t seem to find any way to
load these files with the ruby bindings. Has anyone done this before
or has any other idea how to play the sound?

Are you unable to load them because of the lack of headers or is there
another reason?

If it’s the lack of headers, would it be too difficult to create them
on the fly and then use SDL?

I am trying to play the music from the old game “Ascendancy” using
Ruby, the files are 8-bit unsigned raw PCM files at 22 khz. I thought
about using SDL for playing them, but I can’t seem to find any way to
load these files with the ruby bindings. Has anyone done this before
or has any other idea how to play the sound?

call out to VLC?

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs