Author Topic: Tiny SID Player for Freebasic and C  (Read 52534 times)

0 Members and 1 Guest are viewing this topic.

Offline Jim

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 5301
  • Karma: 402
    • View Profile
Tiny SID Player for Freebasic and C
« on: August 30, 2007 »
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>
« Last Edit: October 01, 2007 by Jim »
Challenge Trophies Won:

Offline Rbz

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 2756
  • Karma: 493
    • View Profile
    • https://www.rbraz.com/
Re: Tiny SID Player for Freebasic and C
« Reply #1 on: August 30, 2007 »
As I said before - AWESOME, this will rock the scene!

 :rockon:
Challenge Trophies Won:

Offline Clyde

  • A Little Fuzzy Wuzzy
  • DBF Aficionado
  • ******
  • Posts: 7271
  • Karma: 71
    • View Profile
Re: Tiny SID Player for Freebasic and C
« Reply #2 on: August 30, 2007 »
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 ):

Code: [Select]
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:

Offline Jim

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 5301
  • Karma: 402
    • View Profile
Re: Tiny SID Player for Freebasic and C
« Reply #3 on: August 30, 2007 »
Ignore the warning.  It's just a warning.

Jim
Challenge Trophies Won:

Offline Clyde

  • A Little Fuzzy Wuzzy
  • DBF Aficionado
  • ******
  • Posts: 7271
  • Karma: 71
    • View Profile
Re: Tiny SID Player for Freebasic and C
« Reply #4 on: August 30, 2007 »
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:

Code: [Select]
'
' 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()
« Last Edit: August 30, 2007 by Clyde »
Still Putting The IT Into Gravy
If Only I Knew Then What I Know Now.

Challenge Trophies Won:

Offline Clyde

  • A Little Fuzzy Wuzzy
  • DBF Aficionado
  • ******
  • Posts: 7271
  • Karma: 71
    • View Profile
Re: Tiny SID Player for Freebasic and C
« Reply #5 on: August 30, 2007 »
Sorted it: I needed an @ before the filename.

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


Cheers and all the very best,
Clyde.
« Last Edit: August 30, 2007 by Clyde »
Still Putting The IT Into Gravy
If Only I Knew Then What I Know Now.

Challenge Trophies Won:

Offline benny!

  • Senior Member
  • DBF Aficionado
  • ********
  • Posts: 4384
  • Karma: 228
  • in this place forever!
    • View Profile
    • bennyschuetz.com - mycroBlog
Re: Tiny SID Player for Freebasic and C
« Reply #6 on: August 30, 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:

Offline slippy

  • Atari ST
  • ***
  • Posts: 172
  • Karma: 42
    • View Profile
Re: Tiny SID Player for Freebasic and C
« Reply #7 on: August 30, 2007 »
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 :)

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

 O0


Offline benny!

  • Senior Member
  • DBF Aficionado
  • ********
  • Posts: 4384
  • Karma: 228
  • in this place forever!
    • View Profile
    • bennyschuetz.com - mycroBlog
Re: Tiny SID Player for Freebasic and C
« Reply #8 on: August 30, 2007 »
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:

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17407
  • Karma: 498
  • evil/good
    • View Profile
    • My Homepage
Re: Tiny SID Player for Freebasic and C
« Reply #9 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+++
Shockwave ^ Codigos
Challenge Trophies Won:

Offline benny!

  • Senior Member
  • DBF Aficionado
  • ********
  • Posts: 4384
  • Karma: 228
  • in this place forever!
    • View Profile
    • bennyschuetz.com - mycroBlog
Re: Tiny SID Player for Freebasic and C
« Reply #10 on: August 30, 2007 »
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:

Offline stormbringer

  • Time moves by fast, no second chance
  • Amiga 1200
  • ****
  • Posts: 453
  • Karma: 73
    • View Profile
    • www.retro-remakes.net
Re: Tiny SID Player for Freebasic and C
« Reply #11 on: August 30, 2007 »
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

Offline va!n

  • Pentium
  • *****
  • Posts: 1432
  • Karma: 109
    • View Profile
    • http://www.secretly.de
Re: Tiny SID Player for Freebasic and C
« Reply #12 on: August 30, 2007 »
@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:

Offline Tetra

  • DBF Aficionado
  • ******
  • Posts: 2532
  • Karma: 83
  • Pirate Monkey!
    • View Profile
Re: Tiny SID Player for Freebasic and C
« Reply #13 on: August 30, 2007 »
Very very cool, thanks very much for posting definately k++
Challenge Trophies Won:

Offline stormbringer

  • Time moves by fast, no second chance
  • Amiga 1200
  • ****
  • Posts: 453
  • Karma: 73
    • View Profile
    • www.retro-remakes.net
Re: Tiny SID Player for Freebasic and C
« Reply #14 on: August 31, 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!
« Last Edit: August 31, 2007 by stormbringer »
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

Offline Clyde

  • A Little Fuzzy Wuzzy
  • DBF Aficionado
  • ******
  • Posts: 7271
  • Karma: 71
    • View Profile
Re: Tiny SID Player for Freebasic and C
« Reply #15 on: August 31, 2007 »
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:

Offline energy

  • Amiga 1200
  • ****
  • Posts: 280
  • Karma: 25
    • View Profile
Re: Tiny SID Player for Freebasic and C
« Reply #16 on: September 03, 2007 »
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

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17407
  • Karma: 498
  • evil/good
    • View Profile
    • My Homepage
Re: Tiny SID Player for Freebasic and C
« Reply #17 on: September 03, 2007 »
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:

Offline Clyde

  • A Little Fuzzy Wuzzy
  • DBF Aficionado
  • ******
  • Posts: 7271
  • Karma: 71
    • View Profile
Re: Tiny SID Player for Freebasic and C
« Reply #18 on: September 03, 2007 »
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.
« Last Edit: September 04, 2007 by Clyde »
Still Putting The IT Into Gravy
If Only I Knew Then What I Know Now.

Challenge Trophies Won:

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17407
  • Karma: 498
  • evil/good
    • View Profile
    • My Homepage
Re: Tiny SID Player for Freebasic and C
« Reply #19 on: September 04, 2007 »
Hmm, dunno, I haven't tried any Psids with it yet. I will do soon though.
Shockwave ^ Codigos
Challenge Trophies Won: