Main Menu

call playsid.library

Started by zerina, 17 May, 2013, 10:25 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

zerina

Again thanks for your help,
i followed your advice and added your example Statement but it still crashes when calling the play.

SamuraiCrow

LVO Setmodule is looking for the locaiton of the file, not the filename.  Your original code just pointed to the filename when calling it.  Set the second parameter of LVO Setmodule to be Start(15).

zerina

Again you are right, but i allready played with start(15), still no joy......

While i was writing these lines i found the solution, the set module has to be called like this.
STATUS=Lvo Setmodule)Start(15),Start(15),M0DULE_LENGTH

The Documentation says
QuoteIn one part files the file location and header could be the same, becuase the function skips the headers.
And now it works, thank you very much for your help

But SID file plays a bit to fast, faster than playing it from Workbench by using the sidplayer.


Lonewolf10

Quote from: zerina on 25 May, 2013, 08:52 PM
And now it works, thank you very much for your help

But SID file plays a bit to fast, faster than playing it from Workbench by using the sidplayer.

Are there any functions in the library that allow you to adjust the speed?

SamuraiCrow

Try "LVO Setvertfreq(50)" before you play it.

zerina

Guys finaly everything works  :D

"LVO Setvertfreq(50)" brought the right speed

i played with icon settings as mentioned in the readme, anyway  the LVO Setvertfreq(50) made it.

Funtastic help here !!!
regards



SamuraiCrow


Hungry Horace

Any chance you cod post your working code, so that others might
A- have working SID files on Amos
B- maybe learn something about library calls in Amos!!!

Thanks!!
Quote from: KillerGorillabecause winuae is made of code and your amiga is made of stuff


zerina

Off course, i will post the code and some explanation

zerina

Final Solution:
(only a small Example without any special error handling)

1) First off all you need the playsid.library and the fd file for the playsid.library
2) By using the FD Builder (can be found here in the Download Section) go an create an Amos-Extension fot the use of the playsid.library
3) Add this new Extension to your Amos enviroment

now add some code to your project.
4.) Open the Library
   Erase All
A=_playsid Base()
If A=0
Print "error"
End If

5.) Init
A=Lvo Allocemulresource()
6)Load a SID File

M0DULE$=Fsel$("*.sid","","Load a ","SID Module")
M0DULE$=M0DULE$+Chr$(0)
Open Random 1,M0DULE$
M0DULE_LENGTH=Lof(1)
Close 1


7) Reserve memory for the  header
Reserve As Work 14,124
SIDHEAD=Start(14)


8) Call Readicon
STATUS=Lvo Readicon(Varptr(M0DULE$),SIDHEAD)

9) Call Checkmodule
STATUS=Lvo Checkmodule(SIDHEAD)

10) Reserve a Bank and load the sid module
Reserve As Work 15,M0DULE_LENGTH : Bload M0DULE$,15
M0DULE_POINTER=Varptr(M0DULE$)


11) Call Setmodule
STATUS=Lvo Setmodule(Start(15),Start(15),M0DULE_LENGTH)

12) Call Setvertfreq (50=PAL)
STATUS=Lvo Setvertfreq(50)

13) Call Startsong(Play tune X)
STATUS=Lvo Startsong(1)

Off Course we need error handling and more functions linke Stopsong, and off course we need to close the lib etc.

BTW can we Build an Small extension wit functions included ?

Again thanks for all the help / support without this would never been possible.

james666

#25
I've been going a little crazy thinking about AmosPro redevelopment so I thought I'd refresh my brain by creating something a bit more self-contained.  The attachment contains a simple extension that serves as a user-friendly AmosPro wrapper for the PlaySid.library.  playsid.lib needs to be copied to the APSystem directory and installed as extension number 20 in the interpreter.  (You can change the extension number if necessary by re-assembling the source.)  The new commands are as follows:

Psload filename, bank number  This loads the module, checks it and copies it to the specified memory bank.  Both header and data are copied to the same bank.  It should work whether the header is in a separate filename.icon file or contained in the main file.  After the bank is created, it can be saved and reloaded as a .abk file using the normal Save and Load commands.

=Psbanklength(bank number) returns the number of songs in the specified bank. 

Psplay bank number, song number plays the specified song.

Psstop stops the music.

Pspause pauses the music. 

Pscontinue resumes music after a Pspause.

Pssetvertfreq frequency can be used to adjust the frequency between PAL (50) and NTSC (60).

Pscloselib stops the music, closes playsid.library and frees its resources.  (The library is automatically opened when the first Ps command is used.)

Known issues: Amos will crash if you attempt to use the normal sound commands and playsid.library at the same time.  Normal sound commands should be OK if playsid is loaded but not actually playing.

A simple example program:
Quote
Psload "andi-music",10
For I=1 to Psbanklength(10)
Psplay 10,I
Wait 400
Next I
Psstop

EDIT - There was a stupid bug in my original attachment that prevented single file SID modules from loading.  Should have tested this first.  A fixed version is attached.

Hungry Horace

Wow! James666 you are bringing a lot of cool new stuff to AMOS!

I had been working on a Horace Goes Skiing remake before, so I can now add the C64 music as an added bonus :)

Looking forward to trying this out :)

Oh... And thanks!
Quote from: KillerGorillabecause winuae is made of code and your amiga is made of stuff


james666

Quote from: Hungry Horace on 01 Jun, 2013, 12:11 AM
I had been working on a Horace Goes Skiing remake before, so I can now add the C64 music as an added bonus :)

The only snag is that playsid.library is rather CPU-heavy.  I believe it's converting 6502 code on the fly as well as emulating the brilliant SID chip.