Searching for a sound unit under FPC 
Author Message
 Searching for a sound unit under FPC

Hi

I'm making a demo and the only thing that is not finished yet is the
sound. The problem is that I would like to play the music as one long
wave file (or more shorter files). I already tried the following:

FPC port of MIDAS unit by Udo Giacomozzi
(I double checked the installation but still I can't even compile it)

SBPLAY by Richard Mulder
(simply generates an general protection fault)

I found both non-functional for my purpose. And since they are both
discontinued projects, I can't get any support for them.

Anyone knows any such free unit for FPC under DOS extender Go32V2? I
only need to play such a wav file in the background so that the unit
will not interfeer with graphics I'm using.

Thanks for any help.

Conrad.
- All about Pascal --------------------------

The Pascal Node - http://www.*-*-*.com/
TomySoftware    - http://www.*-*-*.com/

---------------------------------------------



Wed, 18 Jun 1902 08:00:00 GMT  
 Searching for a sound unit under FPC


Quote:
> FPC port of MIDAS unit by Udo Giacomozzi
> (I double checked the installation but still I can't even compile it)

I just tried it and here it compiles fine. What version of FPC are you
using and what exactly did you try get it to compile?

Jonas



Wed, 18 Jun 1902 08:00:00 GMT  
 Searching for a sound unit under FPC
On Wed, 27 Oct 1999 13:15:19 +0200, Jonas Maebe

Quote:

>I just tried it and here it compiles fine. What version of FPC are you
>using and what exactly did you try get it to compile?

I'm using 0.99.12b version (the latest release). I installed the
MIDAS/FPC over it, following the instructions on page
http://www.guweb.com/midas/install.htm. The sample program that is
included in the installation compiles and runs fine, but when I tried
to play a streaming WAV file, I got this error from the compiler:

****

Free Pascal Compiler version 0.99.12b [1999/07/22] for i386
Copyright (c) 1993-98 by Florian Klaempfl
Target OS: GO32 V2 DOS extender
Compiling sound.pas
sound.pas(59,5) Note: Local variable not used I
sound.pas(60,5) Note: Local variable not used BUFFER
sound.pas(61,5) Note: Local variable not used C
Linking sound.exe
sound.o(.text+0x326):sound.pas: undefined reference to
`MIDASplayStreamWaveFile'

130 Lines compiled, 1.5 sec

****

Here's the program I compiled. As you can see it's only a little
modified sample test program. The only difference is that I use the
MIDASplayStreamWaveFile instead of StreamPolling

****

program StreamTest;

{$MODE Delphi}

uses crt,midasdll;

procedure MIDASerror;
var
  ErrNo : LongInt;
begin
    Write('*** MIDAS error #');
    ErrNo:=MIDASgetLastError;
    write(ErrNo,': ');
    writeln('  ', MIDASgetErrorMessage(ErrNo));
    If ErrNo<>0 then
    begin
      MIDASclose;
      halt;
    end else begin
      writeln('Press ENTER...');
      ReadLn;
    end;
end;

procedure CheckError;
var
  ErrNo : LongInt;
begin
  ErrNo:=MIDASgetLastError;
  If ErrNo<>0 then
  begin
    Write('*** MIDAS error #');
    write(ErrNo,': ');
    writeln('  ', MIDASgetErrorMessage(ErrNo));
    MIDASclose;
  end;
end;

type
    tBufferType = SmallInt;

var
    stream : MIDASstreamhandle;
    i : Integer;
    Buffer : Array[1..1024] of tBufferType;
    c : LongInt;

BEGIN
    if SizeOf(tBufferType)<>2 then
    begin
      writeln('Wrong buffer sample type. Has to be 16-bit integer!');
      Halt;
    end;

    writeln('MIDASstartup');
    MIDASstartup;
    CheckError;

    writeln('MIDASconfig');
    if not MIDASconfig then
    BEGIN
      writeln('Config failed!');
      MIDASerror;
    END;

    writeln('MIDASinit');
    if not MIDASinit then
        MIDASerror;

    writeln('Version: ',MidasGetVersionString);

    writeln('MIDASstartBackgroundPlay(0)');
    if not MIDASstartBackgroundPlay(0) then
        MIDASerror;

    writeln('Opening 1 channel...');
    If not MIDASopenChannels(1) then MIDASerror;

    writeln('Opening stream...');
    stream:=MIDASplayStreamWaveFile('seinfeld.wav', 500,
MIDAS_LOOP_NO);

    writeln('DWORD(stream) = ',DWORD(stream));
    If stream=nil then
    begin
      writeln('MIDASplayStreamWaveFile returned NIL!');
      MIDASerror;
    end;

    writeln;
    writeln('Stream opened successfully in polling mode. Playback will
start');
    writeln('when enough sound data is contained in the stream
buffer.');
    writeln('Hit any key to stop playback!');

    ReadKey;

    writeln;
    writeln('Playback stopped (no more data is being feeded to the
stream).');

    writeln('Stopping stream...');
    If not MIDASstopStream(stream) then midaserror;

    if not MIDASstopBackgroundPlay then
        MIDASerror;
    if not MIDASclose then
        MIDASerror;

  writeln('PROGRAM TERMINATED.');
END.
- All about pascal --------------------------

The Pascal Node - http://come.to/pascalnode
TomySoftware    - http://come.to/tomysoftware

---------------------------------------------



Wed, 18 Jun 1902 08:00:00 GMT  
 Searching for a sound unit under FPC


Quote:
> sound.o(.text+0x326):sound.pas: undefined reference to
> `MIDASplayStreamWaveFile'

> 130 Lines compiled, 1.5 sec

> ****

> Here's the program I compiled. As you can see it's only a little
> modified sample test program. The only difference is that I use the
> MIDASplayStreamWaveFile instead of StreamPolling

You are correct. The reason is clearly stated in the Midas
documentation:

6.3.5. MIDASplayStreamWaveFil
------------------------------
[cut]

Operating systems
    Win32, Linux

So it won't work with the Dos version of Midas (of which the library is
included with the package). For dos, you have to use the polling
method, so you have to load your data in a buffer and then use an
approach similar to the sample program to play the buffer as a stream.
This forces you to decode the wave file manually though...

Maybe you can get that part from the SBPlay package.

Jonas



Wed, 18 Jun 1902 08:00:00 GMT  
 Searching for a sound unit under FPC
On Thu, 28 Oct 1999 12:34:55 +0200, Jonas Maebe

Quote:

>You are correct. The reason is clearly stated in the Midas
>documentation:

>6.3.5. MIDASplayStreamWaveFil
>------------------------------
>[cut]

>Operating systems
>    Win32, Linux

>So it won't work with the Dos version of Midas (of which the library is
>included with the package). For dos, you have to use the polling
>method, so you have to load your data in a buffer and then use an
>approach similar to the sample program to play the buffer as a stream.
>This forces you to decode the wave file manually though...

>Maybe you can get that part from the SBPlay package.

Sorry, I missed that in the manual...

However, I tried that. But using the polling method means that you
must constantly feed the data into the stream - every loop in my
program should have a part in which it reads another part of the file
from the disk and feeds it to the Midas. Here comes trouble with loops
running with different frame rates, ... Besides all that, Midas does
something with the timers so you can not use the "Wait for retrace"
routine.

I tried to fix the SBPlay, but I can't figure out what's wrong. If I
change a minor thing (like if I delete the procedure that writes some
mesages on the screen - nothing to do with the sound unit), it will
crash in a totaly different place (here I mean in different procedure.
The original crashes for example when it comes to the procedure
"startplayer" and the changed program crashes in the procedure
"playsound".

I think it's something wrong with the allocation of the DOS memory
under protected mode.

Conrad
- All about pascal --------------------------

The Pascal Node - http://come.to/pascalnode
TomySoftware    - http://come.to/tomysoftware

---------------------------------------------



Wed, 18 Jun 1902 08:00:00 GMT  
 Searching for a sound unit under FPC


Quote:
> However, I tried that. But using the polling method means that you
> must constantly feed the data into the stream - every loop in my
> program should have a part in which it reads another part of the file
> from the disk and feeds it to the Midas. Here comes trouble with loops
> running with different frame rates, ... Besides all that, Midas does
> something with the timers so you can not use the "Wait for retrace"
> routine.

That's true...

Quote:
> I tried to fix the SBPlay, but I can't figure out what's wrong. If I
> change a minor thing (like if I delete the procedure that writes some
> mesages on the screen - nothing to do with the sound unit), it will
> crash in a totaly different place (here I mean in different procedure.
> The original crashes for example when it comes to the procedure
> "startplayer" and the changed program crashes in the procedure
> "playsound".

Both test programs work for here (and that's under a PC emulator, not
even on a real PC :). If you are running it under Windows, maybe you
could try whether it works under clean Dos?

The modtest does crash with a RTE 204 if I try to have ait play another
modfile than the one supplied (axelf.mod, the Beverly Hills Cop tune).
I have to investigate this further though...

Quote:
> I think it's something wrong with the allocation of the DOS memory
> under protected mode.

The crash I get is in a normal getmem.

Jonas



Wed, 18 Jun 1902 08:00:00 GMT  
 Searching for a sound unit under FPC
Hi again

I gave up on SbPlay and MIDAS, so I decided to write my own simple
unit. I found a very good sound blaster reference (sblaster.doc from
Andr? Baresel - Craig Jackson). It works fine, although it uses almost
the same procedures as the sbplay.  

I omited the mixer part, because I only need to play one file at a
time. And I do not use the sound blaster IRQ to refresh the DMA buffer
in the conventional memory. I simply found a timer unit, that uses the
protected mode interrupts and set it so that it refreshes the buffer
in the right intervals. It works perfect.

Anyway, thanks for your help.

Conrad

- All about pascal --------------------------

The Pascal Node - http://come.to/pascalnode
TomySoftware    - http://come.to/tomysoftware

---------------------------------------------



Wed, 18 Jun 1902 08:00:00 GMT  
 Searching for a sound unit under FPC


Quote:
> I gave up on SbPlay and MIDAS, so I decided to write my own simple
> unit. I found a very good sound blaster reference (sblaster.doc from
> Andr? Baresel - Craig Jackson). It works fine, although it uses almost
> the same procedures as the sbplay.  

> I omited the mixer part, because I only need to play one file at a
> time. And I do not use the sound blaster IRQ to refresh the DMA buffer
> in the conventional memory. I simply found a timer unit, that uses the
> protected mode interrupts and set it so that it refreshes the buffer
> in the right intervals. It works perfect.

In that case, could you please add it to the contributed units section?
I'm sure many other people are also interested in such a unit. Thanks!

Jonas



Wed, 18 Jun 1902 08:00:00 GMT  
 
 [ 8 post ] 

 Relevant Pages 

1. Searching for a sound unit under FPC

2. Q) fpc mysql unit test.

3. FPC Client with sockets unit

4. FPC Listening with Sockets unit

5. Units for FPC

6. FPC - BGI / CHR objects in units?

7. Is there a multitasking unit for Fpc

8. documentation FPC-unit <windows>?

9. no graph unit in FPC win32?

10. FPC: Documentation on Win32 units?

11. FPC Unit for serial port

12. Sound-Unit

 

 
Powered by phpBB® Forum Software