20 Jun '13 - 12:41 *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
 
   Home   Help Search Login Register  
Pages: [1]
  Reply  |  Print  
Author Topic: Delphi StreamTest converting to Linux Lazarus problems  (Read 646 times)
xantippe
Posts: 6


« on: 18 Sep '12 - 12:26 »
Reply with quoteQuote

I'm still looking for a simple start in learning bass under Linux Lazarus/fpc.

Working under LinuxMint 13 maya/mate with FPC 2.6.0 and Lazarus 1.0 I choose the delphi example StreamTest (because it is the smallest axample as far as I can see)

To get the right files I downloaded the zip files bass24.zip and bass24-linux.zip

I put the following files in one directory ~/pascal/projecten/StreamTest/
from bass24.zip /delphi/StreamTest/ STMain.dfm STMain.pas and StreamTest.dpr
And from bass24-linux.zip libbass.o from and here from /pascal/bass.pas

I started up Lazarus (after I deleted the .lazarus file in homedir to make sure I have no side effects)

To setup a project named StreamTest, I choose New Project from file StreamTest.dpr in the ~/pascal/projecten/StreamTest/ dirtectory I have now the StreamTest project.

Than I convert via /tools/Convert Delphi Project to Lazarus Project StreamTest.dpr

Now I add the above mentioned libbass.so and bass.pas to the project via the project/project inspector.

Now I convert via /Tools/ Convert Delphi Unit to Lazarus Unit STMain.pas

In de dir ~/pascal/projecten/StreamTest/ I have the folowing files:
bass.pas , STMain.lfm , STMain.pas , StreamTest.lpi , StreamTest.lpr , met ook libbass.so and
StreamTest.lps and the directories backup and converter backup .

I save all in Lazarus and started a run.

See the attached screendumps: StreamTest1.png  StreamTest2.png StreamTest3.png

Firstly I got (see StreamTest1.png) a STMain.pas/BASS_INIT Error Incompatible type for arg 4 got HWND expected Pointer.

I changed the 4th arument handle in nil, just to see what will happen.

I did a new run (see StreamTest2.png). I see a lot of warnings but project "StreamTest¨ is successfully built and the programs form shows on the screen.

I'M A BEGINNER WITH AUDIO PROGRAMMING UNDER FPC/LAZARUS/LINUX
I do not know much about audio channels and all the details used in BASS.

So I just went on and pushed on button 1) "Initialize BASS"
No error message and the following button 2) "Create a user stream" is enabled.
I pushed on button 2.
No error message and the following button 3) "Start stream playback" is enabled.

I pushed on button 3.
Now I got an access violation see screendump StreamTest3.png

= = = =
These test are without a working debugger.
After using the gdb debugger I got "Project StreamTest raised exception class
External: SIGSEGV' at address 15CC40" and the assembler is shown.
= = = =

I have a question:

1.What did I wrong?

2.If yofile:///home/xantippe/Bureaublad/StreamTest1.png
u think it is better for me to start with a simpeler program to learn BASS let me know.













I add the other screendumps

first screendump StreamTest1.png

Thies;]

* StreamTest3.png (401.14 KB - downloaded 39 times.)
* StreamTest1.png (569.55 KB - downloaded 37 times.)
Logged
xantippe
Posts: 6


« Reply #1 on: 18 Sep '12 - 12:28 »
Reply with quoteQuote

And screendump StreamTest2.png

Thies;]

* StreamTest2.png (427.06 KB - downloaded 37 times.)
Logged
Ian @ un4seen
Administrator
Posts: 15366


« Reply #2 on: 18 Sep '12 - 17:50 »
Reply with quoteQuote

I pushed on button 3.
Now I got an access violation see screendump StreamTest3.png

= = = =
These test are without a working debugger.
After using the gdb debugger I got "Project StreamTest raised exception class
External: SIGSEGV' at address 15CC40" and the assembler is shown.
= = = =

If Lazarus doesn't include a debugging option, then you could instead use logging to locate where the crash is occurring. I suspect it'll be in the MakeSine function (that's passed to BASS_StreamCreate), so you could first try logging the entry and exit of that function.

u think it is better for me to start with a simpeler program to learn BASS let me know.

What do you ultimately want to do in your own apps? Unless you want to play custom generated waveforms, I think it would be better to start with one of the other examples from the BASS package.
Logged
xantippe
Posts: 6


« Reply #3 on: 19 Sep '12 - 11:17 »
Reply with quoteQuote

Thanks for your quick reaction.

I tested the program with the GNU Debugger gdb. Wich is available from the Lazarus Tools menu, see screen dump LazarusDebugger.png. (they are designing an own debugger wich comes later)

It went as follows:
See screendump StreamTestDebug1.png See the messages that gives a lot of warnings and hints.
But you can see the project "StreamTest" is successfully built and I can see the result with the form and the buttons 1,2 and 3 etc. Button 1 has been enabled.

1.I pushed on button 1)"Initialize Bass" No error messages. And button 2) has been enabled.
2.I pushed button 2) "Create a user stream" No error message. Ans button 3) has been enabled.
3.I pushed button 3) "Start stream playback"
Now I got an Error as shown on Screendump StreamTest Debug2.png. It says: "Project StreamTest raised exeption class 'External: SIGSEGV' at address 15CC40.

I pushed on OK and than the assembler comes up, see screendump StreamTestDebug3.png
It gives me the following possibilities:
"Step into instruction"
"Step over instruction"
or
"Goto current address"

Well I can do a lot of things. Please instruct me if possible.

Thanks a lot.

====

To explain what I like to do with BASS:

In Holland the C'T magazine started with a Pascal course. Amongst others they gave a windows example of the singing Nightingale using the windows MMSystem library for the audio part.

A part of the program is a "simple"

procedure TfrmNightingale.imgNightingaleClick(Sender: TObject);
begin
  // must be wav files...
  sndPlaySound('..\wav\NightingaleStory.wav', SND_FILENAME or SND_ASYNC);
  Timer1.Enabled := True;
end
uses the sndPlaySound(...) to play the song.

So I contacted the Blaise Pascal group in Holland and asked if I could convert the program for my linux/fpc/Lazarus environment. They advised me to look for the BASS library to find a solution because at the momment we do not have a replacement for the MMSystem library.

Actually my question is do you have in BASS a "simple" solution for playing the song?
I like to use that as a start in studying programming audio.
Including all the details of using audio under linux/alsa/pulse audio etc

Knowing this you can perhaps give me a hint how to begin learning the BASS library?

Thanks, Thies;]

* LazarusDebugger.png (108.24 KB - downloaded 26 times.)
* StreamTestDebug1.png (299.54 KB - downloaded 26 times.)
* StreamTestDebug3.png (256.66 KB - downloaded 28 times.)
Logged
xantippe
Posts: 6


« Reply #4 on: 19 Sep '12 - 11:22 »
Reply with quoteQuote

I think you missed the screendump with the error message so I add that here.
Thies;]

* StreamTest Debug2.png (323.16 KB - downloaded 26 times.)
Logged
Ian @ un4seen
Administrator
Posts: 15366


« Reply #5 on: 19 Sep '12 - 11:43 »
Reply with quoteQuote

To explain what I like to do with BASS:

In Holland the C'T magazine started with a Pascal course. Amongst others they gave a windows example of the singing Nightingale using the windows MMSystem library for the audio part.

A part of the program is a "simple"

procedure TfrmNightingale.imgNightingaleClick(Sender: TObject);
begin
  // must be wav files...
  sndPlaySound('..\wav\NightingaleStory.wav', SND_FILENAME or SND_ASYNC);
  Timer1.Enabled := True;
end
uses the sndPlaySound(...) to play the song.

OK. To play an audio file with BASS, the bare bones code could look something like this...

BASS_Init(-1, 44100, 0, 0, 0); // initialize default output device
stream=BASS_StreamCreateFile(FALSE, filename, 0, 0, 0); // create a stream to play a file
BASS_ChannelPlay(stream, 0); // start playing it
...
BASS_StreamFree(stream); // free the stream
BASS_Free(); // release the output device

If you want to play a file and forget about it (automatically free it when done playing), then you can add the BASS_STREAM_AUTOFREE flag to the BASS_StreamCreateFile call. Please see the documentation for details on the aforementioned functions.
Logged
Pages: [1]
  Reply  |  Print  
 
Jump to:  

Powered by SMF 1.1.18 | SMF © 2013, Simple Machines