• Welcome to Dark Bit Factory & Gravity.
 

Tiny SID Player for Freebasic and C

Started by Jim, August 29, 2007

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Jim

Quote
TinySID player library for Win32
--------------------------------
30/9/2007

This library enables small programs to be built that can play many C64 SID music files.
Bindings for Freebasic, C and C++ are provided.
Example source and binaries can be found in the Examples folder.

Credits
-------
Based on the work of
Tammo Hinrichs - 6510 and SID routines
Rainer Sinsch  - PSP TinySID

Many, many thanks to these people.  They are the technical wizards behind this work
and deserve the credit for this great release.

See
http://www.informatik.uni-frankfurt.de/~sinsch/TinySid.htm
http://www.syntheticsw.com/~sinsch/?id=7298b&s=k2
http://www.syntheticsw.com/~sinsch

Removal of runtime library dependency
Packing as a lib
Simple calling interface
DirectX playback routines
Freebasic/C/C++ bindings - Jim Shaw
See
http://www.dbfinteractive.com

Usage
-----

int SID_init(void);
Start the SID player environment

int SID_loadsong(void *song, unsigned short size, int type);
Load a song
Either
SID_loadsong("file.sid", 0, SID_TYPE_FILE);
SID_loadsong(address, length, SID_TYPE_MEMORY);

int SID_get_num_subsongs(void);
Get the number of subsongs in the SID

int SID_play(int subSong);
Start playing the subsong (numbering starts at 0)

int SID_stop(void);
Stop playing

int SID_shutdown(void);
Shutdown the SID player

short *SID_get_raw_data(void);
Retrieve the last 22050 (1/2 second) 16bit samples of raw audio data
Returns NULL or 0 if no new data is available since the last call.

All functions return 0 on success, and positive values on failure.

You may need to add dsound.lib and dxguid.lib to the library dependencies.

To switch between different SID files, call SID_shutdown and SID_init to restart the engine.

Have fun!

Jim

<edit>2/10/07. Updated the library with a little sample code and some bug fixes.
Also, added a couple of functions
SID_set_volume(0 to 127) which Clyde wanted, and
SID_get_details() which can return the song name, author and copyright details.
Check the sample for usage details.
</edit>
Challenge Trophies Won:

Rbz

As I said before - AWESOME, this will rock the scene!

:rockon:
Challenge Trophies Won:

Clyde

Wicked stuff Jim & Co.

I hope im correct in putting the libtinysid.a file into lib\win32 and the tinysid.bi into the includes directory?

When running the Sidresource example. I get this error in the compiler log under Freebasic 17 ( allthough it does compile the dotty example ):

Warning: .drectve `/DEFAULTLIB:"uuid.lib" /DEFAULTLIB:"uuid.lib" ' unrecognized

I love sid tunes, so plenty Karma for this one, welldone Jim.
Still Putting The IT Into Gravy
If Only I Knew Then What I Know Now.


Challenge Trophies Won:

Jim

Ignore the warning.  It's just a warning.

Jim
Challenge Trophies Won:

Clyde

#4
Ok thanks Jim :)

With this code for loading a sid from a file, for some reason I get an type mismatch error at parameter 1:


'
' Load a sid song
' Cheers Jim Shaw for TinySid for FB
'

Option Static
Option Explicit

#Include Once "Tinyptc.bi"
#include Once "tinysid.bi"
#Include Once "Windows.bi"

Const XRES=640
Const YRES=480

Const ARES=XRES*YRES

Dim Shared ScreenBuffer(ARES)

PTC_Open("boo",XRES,YRES)

'Init
SID_init()
Sid_loadsong( "comic_Bakery.sid",0, SID_TYPE_FILE)
SidPlay(0)
   
Dim Key As String

While Key<>Chr(27)
   
    PTC_Update @ScreenBuffer(0)
   
Wend

SID_stop()
SID_shutdown()
PTC_Close()
Still Putting The IT Into Gravy
If Only I Knew Then What I Know Now.


Challenge Trophies Won:

Clyde

#5
Sorted it: I needed an @ before the filename.

SID_loadsong( @"comic_Bakery.sid",0, SID_TYPE_FILE)


Cheers and all the very best,
Clyde.
Still Putting The IT Into Gravy
If Only I Knew Then What I Know Now.


Challenge Trophies Won:

benny!

Quote from: rbraz on August 29, 2007
As I said before - AWESOME, this will rock the scene!

:rockon:

What rbraz said !!!
[ mycroBLOG - POUET :: whatever keeps us longing - for another breath of air - is getting rare ]

Challenge Trophies Won:

slippy

Jim,

that's awesome ... I already had the same idea to do a SID lib for FB and stuff - but unfortunately didn't find the time for this ...

have some K++ from me for that ...

ahhh ... btw. thanks for sharing stuff from the future :)

QuoteQuote
TinySID player library for Win32
--------------------------------
30/9/2007

O0


benny!

lol ... I already knew that Jim is very clever - but I didn't know that he
invented time travelling  ;D  N1, Jim
[ mycroBLOG - POUET :: whatever keeps us longing - for another breath of air - is getting rare ]

Challenge Trophies Won:

Shockwave

As you know Jim, I love this library and really appreciate you releasing it :)
The other great thing is that it's so damned small!

I am coding a promotional intro for the forum with a collection of Rob Hubbards songs,  really looking forward to seeing some nice C64 remakes :) And just hearing some sid tunes.

K+++
Shockwave ^ Codigos
Challenge Trophies Won:

benny!

So true. I also hope that with the release of this library there will be some
future releases including some cool SID tunes. The sound of SID is just un-
beatable !!!
[ mycroBLOG - POUET :: whatever keeps us longing - for another breath of air - is getting rare ]

Challenge Trophies Won:

stormbringer

expect some C64 remakes soon...
We once had a passion
It all seemed so right
So young and so eager
No end in sight
But now we are prisoners
In our own hearts
Nothing seems real
It's all torn apart

va!n

@jim:
I know the tinySID replayer by Myth (Rainer Sinsch) long time ago... and i am very very happy you managed to convert the source for the PSP version back to Windows! Great! K++ for this great work!
:goodpost:
- hp EliteBook 8540p, 4 GB RAM, Windows 8.1 x64
- Asus P5Q, Intel Q8200, 6 GB DDR2, Radeon 4870, Windows 8.1 x64
http://www.secretly.de
Challenge Trophies Won:

Tetra

Very very cool, thanks very much for posting definately k++
Challenge Trophies Won:

stormbringer

#14
Quote from: Shockwave on August 30, 2007
As you know Jim, I love this library and really appreciate you releasing it :)
The other great thing is that it's so damned small!

I am coding a promotional intro for the forum with a collection of Rob Hubbards songs,  really looking forward to seeing some nice C64 remakes :) And just hearing some sid tunes.

K+++

here it is... http://dbfinteractive.com/index.php?topic=2340.0

although as you may notice, the music does not restart automatically and I did not find any looping function in the lib... any suggestion?

Have fun!
We once had a passion
It all seemed so right
So young and so eager
No end in sight
But now we are prisoners
In our own hearts
Nothing seems real
It's all torn apart

Clyde

I've found a few problems with certain sid files, mostly ones that contain samples.

Is there a volume function?

Excellent lib and welldone Jim,
Clyde.
Still Putting The IT Into Gravy
If Only I Knew Then What I Know Now.


Challenge Trophies Won:

energy

Thanx a lot!   :goodpost:

Runs fine with purebasic too!!

Just had to change my dsound.lib!

Best regards
coding: jwasm,masm
hobby: www.scd2003.de

Shockwave

Cool :)

By the way, please wait about 100ms after initialising the sid library as we have found a small problem with it. It will be fixed though :) An update will be posted as soon as it is available.
Shockwave ^ Codigos
Challenge Trophies Won:

Clyde

#18
Wicked one can't wait :)

Also, can the lib play any type of .Sid as some are in PSid format, Or do they need converting?

Cheers,
Clyde.
Still Putting The IT Into Gravy
If Only I Knew Then What I Know Now.


Challenge Trophies Won:

Shockwave

Hmm, dunno, I haven't tried any Psids with it yet. I will do soon though.
Shockwave ^ Codigos
Challenge Trophies Won: