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

0 Members and 1 Guest are viewing this topic.

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 #60 on: July 05, 2008 »
Here it is:

  TinySID v1.0 Generic Replay

  based on PSP original source code by Tammo Hinrichs & Rainer Sinsch

  changes made:

  - removed any platform/audio device/audio mechanism dependency
  - original comments kept
  - code cleaned
  - added new comments to make code clearer to read
  - functions renamed to avoid conflict with other functions in client programs (all have sid_ prefix now)
  - removed local variables
  - added SIDEmulator structure that holds the state of the emulator (memory, registers, etc)
  - changed the compilation-time audio filtering with a run-time audio filtering flag

  instructions:

  1) declare a variable of the type SIDEmulator (emulator state)
  2) call sid_emu_init() with the address of the emulator state variable and replay frequency (e.g. 44100)
  3) call sid_emu_load_from_mem() with the address of the emulator variable and the address and size of the SID tune
   to be loaded in the emulator memory
  4) call sid_emu_process_begin() with the address of the emulator variable and the number of the sub-song (zero-based number) to be replayed
   you may want to call sid_emu_get_subsong_count() before to know how may sub-songs are contained in the file
  5) call sid_emu_process() during your audio interrupt/callback to render new samples.

  NOTE: the audio stream is rendered as MONO not STEREO!
  NOTE2: you may call sid_emu_audio_filter() to turn on and off the audio filtering (works at run-time)


Archive includes Win32 WaveOut sound server example in C.

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

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 #61 on: July 06, 2008 »
Welldone, I guess I'll make a FB port ;)
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 #62 on: July 06, 2008 »
That would be very cool indeed.  8)
Still Putting The IT Into Gravy
If Only I Knew Then What I Know Now.

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 #63 on: July 06, 2008 »
@Rbraz: definitely needed I guess. By reading this thread, I think a lot of people are waiting for a lib that fixes the bugs of the past one... it should be easier now with the source code..
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 #64 on: July 06, 2008 »
Can it play RSID tunes as well as PSID?

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

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 #65 on: July 06, 2008 »
AFAIK it only plays PSIDs... I did not look into RSIDs yet. I just cleaned the original code (which is not by me) and made it available here so we can have this lib whithout the need to link DirectX and other crap in order to replay some good old tunes ;)
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 stormbringer

  • Time moves by fast, no second chance
  • Amiga 1200
  • ****
  • Posts: 453
  • Karma: 73
    • View Profile
    • www.retro-remakes.net
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 Rbz

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 2756
  • Karma: 493
    • View Profile
    • https://www.rbraz.com/
Re: Tiny SID Player for Freebasic and C
« Reply #67 on: July 06, 2008 »
Ok, it's done  :)

I did a little change on original "sid_sound_server_replay_init" function, I use it to pass song parameters to the emulator.
Check out example test included.

 :cheers:
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 #68 on: July 06, 2008 »
@stormbringer+rbz:
K++ to you both (when I can give K again). Great work.

@stormbringer:
thanks a lot for that cool Rob videos. Brings a lot of
memories back - very retro  O0
[ 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 #69 on: July 06, 2008 »
You know what, having the directx one that Jim ported was really nice, I was dissapointed when it wouldnt work reliably everywhere though. This is not Jim's fault, Direct X is lame and cannot be guaranteed to work anywhere and should be banished to the bottom of the deepest ocean where there is no light and it can be eaten by deformed sea creatures.

Now there is a viable and working version that uses Hwave!

So I will respectfully tip my hat to these people;

Jim (for getting the ball rolling).
Stormbringer for the hard work in porting this and giving it to the community.
Rbz for the lightning quick port over to Freebasic.

Yes, we have the best selection of working sound libraries anywhere on the scene in this forum and for helping that remain the case, K + 10 to all three of you.

Thank you very very very much.
Shockwave ^ Codigos
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 #70 on: July 06, 2008 »
@benny! & Shockwave: thanks you guys! It was not really "hard work" as the original code did not have issues with compilation or anything. It was just done by somebody who seems to be a student in computer science and done for what seemed to be a school's end-of-the-year project. I mean by that that the code was not very structured and organized. I just "cleaned the house" a bit.

Note to developers: if you want to reuse the replay routine only (C/C++) version, just steal the sid_emu.c and sid_emu.h files from the archive. The WaveOut sound server was provided as an example. The core routines just render the samples into a provided buffer. Then you can redirect the buffer to whatever you want: WaveOut, DirectSound, etc.

Since now the emulator's state is contained in a structure, it is multi-thread safe and you can have several SID emulators running in parallel. That can be usefull for cross-fading between songs, etc.

It is also a good practice to keep the replay routine separated from the audio output mechanism. The example I provided could work well for a simple production (intro/demo) but I would not use it "as is" for something more complex, like a player (e.g. WinAmp, etc).
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 energy

  • Amiga 1200
  • ****
  • Posts: 280
  • Karma: 25
    • View Profile
Re: Tiny SID Player for Freebasic and C
« Reply #71 on: July 06, 2008 »
Wow Stormbringer!!  :goodpost:
Thanx and k++ for this cool Prod....

Runs FINE with RRAZ LIB Version under PUREBASIC....
I'll deliver tomorrow the Purebasic version with source...

@Stormbringer and RBRAZ:   :-*

Cheers
eNeRGy
coding: jwasm,masm
hobby: www.scd2003.de

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 #72 on: July 06, 2008 »
@energy: thanks mate!

@energy+rbraz: may I ask you to upload your libs here : http://retro-remakes.net/index.php?board=64.0

Thanks in advance!
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 energy

  • Amiga 1200
  • ****
  • Posts: 280
  • Karma: 25
    • View Profile
Re: Tiny SID Player for Freebasic and C
« Reply #73 on: July 06, 2008 »
Ofcourse ill do!! ;)
coding: jwasm,masm
hobby: www.scd2003.de

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 #74 on: July 07, 2008 »
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 energy

  • Amiga 1200
  • ****
  • Posts: 280
  • Karma: 25
    • View Profile
Re: Tiny SID Player for Freebasic and C
« Reply #75 on: July 08, 2008 »
Hi!
Here's conversion for Purebasic.
Big thanx go to Stormbringer and Rbraz for this great Lib...   :-*

Cheers eNeRGy


http://retro-remakes.net/index.php?topic=226.0
coding: jwasm,masm
hobby: www.scd2003.de

Offline mudlord

  • ZX 81
  • *
  • Posts: 8
  • Karma: 7
    • View Profile
Re: Tiny SID Player for Freebasic and C
« Reply #76 on: July 19, 2008 »
Awesome! I just noticed this and its pretty nice for its size!

All we need now is a decent AHX/HVL library in the same fashion!

*hint hint*....

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 #77 on: July 19, 2008 »
will come.... just a bit of patience ;)
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 Jim

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 5301
  • Karma: 402
    • View Profile
Re: Tiny SID Player for Freebasic and C
« Reply #78 on: July 21, 2008 »
There is an AHX library around here somewhere too.  I used it in my Scroller demo... If anyone wants that source please just ask.  It's had a number of fixes and now doesn't rely on a C runtime, plus, for those luddites, it can be configured to use WaveOut instead of DirectSound.

<edit>
http://dbfinteractive.com/forum/index.php?topic=990.0
It was one of m0d's tunes I used.  Great tune, I just wish he'd hung around long enough for the K!

Jim
« Last Edit: July 21, 2008 by Jim »
Challenge Trophies Won:

Offline turkeybaster5723

  • ZX 81
  • *
  • Posts: 3
  • Karma: 0
    • View Profile
Re: Tiny SID Player for Freebasic and C
« Reply #79 on: November 12, 2014 »
I'm considering porting this to AS3/Flash. Cause that's my thing, really. And, errrrr, masochism, yes.
I do remember TinySID being an unreliable mess and am currently looking at this 1.0 version.

Welp, here's my introductory post, and with it, my first necrobump.

Cheers *hides*