Forum: Ruby Problems With DirectSound & DL

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Philip W. (Guest)
on 2007-07-02 07:42
(Received via mailing list)
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  <meta content="text/html;charset=ISO-8859-1"
<body bgcolor="#ffffff" text="#000000">
Hello Everyone,<br>
&nbsp;&nbsp;&nbsp; I'm trying to make an MP3 player in Ruby. I would
like to make it
in pure Ruby, but I've come to the conclusion that Ruby is too high
level to mess around with sound buffers and such. So I'm making the MP3
player in Ruby, and using DL and dsound.dll to access the DirectSound
API. But I'm having trouble invoking IDirectSound8::SetCooperativeLevel
as mentioned on <a
I've tried every way I could think of to try to get it to run, but with
no success. Below is the Ruby code that I have so far. I know its
messy, and I'm planning to do a rewrite of it before I distribute it.
Right now I'm just trying to learn how to accomplish invoking the
The code:<br>
require 'dl'<br>
require 'dl/import'<br>
require 'pp'<br>
hello_me = DL.malloc(DL.sizeof('P'))<br>
hwnd = DL.malloc(DL.sizeof('P'))<br>
dsound = DL.dlopen('dsound')<br>
soundobject1 = dsound['DirectSoundCreate8', 'LSPS']<br>
pp, hello_me, nil)<br>
pp hello_me<br>
module Blah<br>
extend DL::Importable<br>
def self.setCooperativeLevel(ptr, appwindow=0, priority='ii')<br>
coopthing =<br>
coopthing += "#{ptr.to_ptr}"<br>
coopthing += "-&gt;SetCooperativeLevel("<br>
&nbsp;if appwindow == 0 then<br>
coopthing += "hwnd"<br>
coopthing += appwindow<br>
if priority == 'ii' then<br>
coopthing += ", DSSCL_PRIORITY)"<br>
coopthing += ", " + priority + ")"<br>
pp coopthing<br>
extern "#{coopthing}"<br>
pp Blah.setCooperativeLevel(hello_me)<br>
I'm running Windows XP Professional.<br>
Philip W.<br>
This topic is locked and can not be replied to.