Dark Bit Factory & Gravity

PROGRAMMING => General coding questions => Topic started by: slippy on October 04, 2007

Title: Tiny Future Composer Player for C/C++, FreeBasic and PureBasic
Post by: slippy on October 04, 2007
Quote
Tiny Future Composer library for Win32
--------------------------------------
04/10/2007

This library is a tiny implementation of the well-known and famous amiga-based Future Composer sound format

Credits:
Original FC replayer core coding by Michael Schwendt (back in 1997)
optimized and packed as static library with own background threaded DirectX replayer by SLiPPY/VeCTRONiX!



Usage
-------

int FC_Initialize(bool inMem, void* pMusicBuffer, int inMemSize, char* filename);
called once for initialization of the replayer
either use it with a pointer to the FC module or provide a filename for it (don't forget the inMem switch)

int FC_StartPlayer();
starts the current song

int FC_StopPlayer();
stops the current song


Perhaps you might want to add additional language bindings ... :)

As this package is more than 300kb it's not attached ... so you may download it here (http://www.dbfinteractive.com/demos/tiny_fc_replayer_v097.zip)

Have fun using it ...

SLiPPY
Title: Re: Tiny Future Composer Player for C/C++, FreeBasic and PureBasic
Post by: benny! on October 04, 2007
Awesome work, slippy. Thanks so much for releasing this lib !!!
K++
Title: Re: Tiny Future Composer Player for C/C++, FreeBasic and PureBasic
Post by: Clyde on October 04, 2007
That is indeed awesome work.

For Freebasic users, which files go where please Slippy dude?

Ps. Where do we get Future Composer modules?

Cheers and all the very best,
Clyde
Title: Re: Tiny Future Composer Player for C/C++, FreeBasic and PureBasic
Post by: stormbringer on October 04, 2007
@Clyde: go here: http://www.exotica.org.uk/frames.html and select Tunes and then you have a list of tunes per format. Search for FutureComposer (FC13 FC14) and you get a link with dozens of them

or you can find some others here too: ftp://ftp.modland.com/pub/modules/
Title: Re: Tiny Future Composer Player for C/C++, FreeBasic and PureBasic
Post by: Clyde on October 04, 2007
Thanks for the links Stormbringer dude :)
Title: Re: Tiny Future Composer Player for C/C++, FreeBasic and PureBasic
Post by: Rbz on October 05, 2007
Great library slippy, well done

:cheers:
Title: Re: Tiny Future Composer Player for C/C++, FreeBasic and PureBasic
Post by: va!n on October 05, 2007
cool... cant test it atm :(  will take closer look later when i get back own internet... (i die without internet and livestream radio ^^)
Title: Re: Tiny Future Composer Player for C/C++, FreeBasic and PureBasic
Post by: energy on October 05, 2007
 :goodpost:
Hi Slippy!
Thanks for this great peace of soft...

Purebasic 4.1Beta3
Tested DLL included in Exe.... runs perfect....    ;D

But a Problem with Static Lib from the VC++ Folder...
Compiler gets an error: "Unresolved external symbol: __iob_func"    ???
Dsound.lib is included...
Can yu help me?
Thanx
Best regards
eNeRGy

Title: Re: Tiny Future Composer Player for C/C++, FreeBasic and PureBasic
Post by: Clyde on October 05, 2007
I use Freebasic, and am unsure where to put the relevant files. Is there a readme?

Cheers and awesome stuff,
Clyde
Title: Re: Tiny Future Composer Player for C/C++, FreeBasic and PureBasic
Post by: Shockwave on October 05, 2007
K++ For the great lib!

Clyde, treat the files the same as the tinysid lib files.
In fact if you put them all in your usual source directory it should even work like that.
Title: Re: Tiny Future Composer Player for C/C++, FreeBasic and PureBasic
Post by: Clyde on October 05, 2007
Thanks dude.
Title: Re: Tiny Future Composer Player for C/C++, FreeBasic and PureBasic
Post by: slippy on October 05, 2007
@Clyde: apologies for not including a simple readme.txt - thought my samples would answer most of the usage questions ;) Anyway ... just do it like Shocky said ... :)

@energy: static linking with PB? Perhaps you might want to use the library which is located in the MinGW folder ... this one works very well for FB ... else I have to hand over the question to a PB-crack here ;)

@rest: thanks for your feedback ... :)

Cheers,
SLiPPY
Title: Re: Tiny Future Composer Player for C/C++, FreeBasic and PureBasic
Post by: Shockwave on October 05, 2007
The sample listings were clear enough Slippy :) and anyway, any problems that come up can be answered here... You do not need to apologise for anything! It's a great lib and I'm grateful for it! So will most other people.  :)
Title: Re: Tiny Future Composer Player for C/C++, FreeBasic and PureBasic
Post by: Clyde on October 05, 2007
I think its an awesome library and am going to produce a production with it.

I've put the libstc++.a and the libtiny_fc.a into the lib folder, and the tiny_fc.bi into the include folder. And this is an experiment with your neat library in conjunction with tinyptc / tinyptc_ext


Option Explicit
Option Static


#Include Once "tinyPTC.bi"
#include Once "tiny_fc.bi"
#Include Once "Windows.bi"

Const XRES=640
Const YRES=480
Const ARES=XRES*YRES

Dim Shared ScreenBuffer( ARES )
dim shared dummy as integer



If( ptc_open( "testing", XRES, YRES ) = 0 ) Then
   End -1                                    
End if


initFC(0, @dummy, 0, "sample.fc")
startFC()

Dim Key As String

While Key<>Chr(27)
   
   
   PTC_Update @ScreenBuffer(0)
   key=Inkey

Wend


stopFC()
PTC_Close()


But I don't get any sound at all, and also the program crashes when it ends on a key press. It might be something I am doing wrong. Btw, im using FB 17

Cheers,
Clyde.
Title: Re: Tiny Future Composer Player for C/C++, FreeBasic and PureBasic
Post by: Shockwave on October 05, 2007
Do the example programs that Slipy provided compile and run Clyde?
Title: Re: Tiny Future Composer Player for C/C++, FreeBasic and PureBasic
Post by: Clyde on October 05, 2007
Yes they do dude.
Title: Re: Tiny Future Composer Player for C/C++, FreeBasic and PureBasic
Post by: Shockwave on October 05, 2007
Then in that case you should use that code as your base and build around it.
Title: Re: Tiny Future Composer Player for C/C++, FreeBasic and PureBasic
Post by: Clyde on October 05, 2007
More Karma for you Slippy++, and thanks for the tip Shockwave.

Changed around a few things and it works. Hoe this basis is of use to others too.



Option Explicit
Option Static


#Include Once "tinyPTC.bi"
#include Once "tiny_fc.bi"
#Include Once "Windows.bi"

Const XRES=640
Const YRES=480
Const ARES=XRES*YRES

Dim Shared ScreenBuffer( ARES )
dim shared dummy as integer

initFC(0, @dummy, 0, "sample.fc")
startFC()

If( ptc_open( "testing", XRES, YRES ) = 0 ) Then
    End -1                                   
End if




Dim Key As String

While Key<>Chr(27)
   
   
    PTC_Update @ScreenBuffer(0)
    key=Inkey

Wend


PTC_Close()
stopFC()
Title: Re: Tiny Future Composer Player for C/C++, FreeBasic and PureBasic
Post by: slippy on October 05, 2007
@Clyde: Glad you like the lib ... and hey, of course I'm looking forward to see your prods using the lib ;)

Title: Re: Tiny Future Composer Player for C/C++, FreeBasic and PureBasic
Post by: Shockwave on October 05, 2007
Glad you got it working Clyde :)
Title: Re: Tiny Future Composer Player for C/C++, FreeBasic and PureBasic
Post by: Clyde on October 06, 2007
Thanks. :D

I am getting crashes whenever the program stops with using TinyPTC. Try out the listing above, and see if it does the same for you.

Cheers and much appreciated,
Clyde
Title: Re: Tiny Future Composer Player for C/C++, FreeBasic and PureBasic
Post by: energy on October 06, 2007
Hi Slippy

Yes... where ever i can i use the Static Lib with Purebasic! (u can do that with the commando Import(StaticLib)
it seems that theres an export from MSVCR70.dll
Will test with the other lib from MinGW

Cheers eNeRGy
Title: Re: Tiny Future Composer Player for C/C++, FreeBasic and PureBasic
Post by: slippy on October 06, 2007
Hey Clyde,

I didn't encounter any problems when quitting a TinyPTC project ... attached there's a little example (although it's been compiled with FB 0.18 ... perhaps this is the solution to your problem??!)

I wonder if it crashes on your PC upon exit ... please let me know ...

@energy: I just tried it myself and I get unresolved symbol errors on compile - I'm no PB crack ... sorry - perhaps we might hand over this question to some of the other guys here ... :/

SLiPPY

Title: Re: Tiny Future Composer Player for C/C++, FreeBasic and PureBasic
Post by: Clyde on October 06, 2007
Ace SLiPPY K++ works great in FB 18, thanks for the info and help.

Note: Just to let you know using the TinyPTC_Ext still produces the error upon exitting.

Cheers and all the very best,
Clyde.
Title: Re: Tiny Future Composer Player for C/C++, FreeBasic and PureBasic
Post by: Jim on October 07, 2007
Just as an experiment, try stopping the FC player before exiting PTC.
Jim
Title: Re: Tiny Future Composer Player for C/C++, FreeBasic and PureBasic
Post by: Clyde on October 07, 2007
Tried that Jim, and still occurs.
Title: Re: Tiny Future Composer Player for C/C++, FreeBasic and PureBasic
Post by: Shockwave on October 07, 2007
Please post the latest source so that the problem can be fixed.. Thanks :)
Title: Re: Tiny Future Composer Player for C/C++, FreeBasic and PureBasic
Post by: Clyde on October 07, 2007

'
' Random Pixels Experiment with Future Composer
' Freebasic Version 18

Option Explicit
Option Static


#Include "tinyPTC.bi"'         "TinyPTC_Ext.bi"
#include "tiny_fc.bi"

Const XRES=640
Const YRES=480
Const ARES=XRES*YRES

Dim Shared ScreenBuffer( ARES )
dim shared dummy as integer

Declare Sub FeedPixels  ( Byval X As Integer, ByVal Y As Integer, Byval Col As Integer )

Declare Sub InitializeExperiment()
Declare Sub RunExperiment()
Declare Sub ShutDownExperiment()

Declare Function Randd(ByVal lower as integer, ByVal upper as integer) As Integer

InitializeExperiment()
RunExperiment()
ShutDownExperiment()


Sub FeedPixels  ( Byval X As Integer, ByVal Y As Integer, Byval Col As Integer )
   
    If X>0 And X<XRES-1 And Y>0 And Y<YRES-1 And Col<>0  Then
        ScreenBuffer( X + ( Y * XRES) ) = Col
    End If   
End Sub

Sub InitializeExperiment()

    initFC(0, @dummy, 0, "slipstream2.fc")
    startFC()
   
    If( ptc_open( "testing", XRES, YRES ) = 0 ) Then
        End -1                                   
    End if
   


End Sub

Sub RunExperiment()

    Dim Key As String
   
    Dim x,y
   
    While Key<>Chr(27)
       
        For y=0 To YRES-1
            For x=0 To XRES-1
               
                FeedPixels(x,y,Randd(0,&HFFFFFF))
       
            Next
        Next
       
       
        PTC_Update @ScreenBuffer(0)
        key=Inkey
    Wend

End Sub


Sub ShutDownExperiment()
   
    stopFC()   

    PTC_Close()

End Sub


Function Randd(ByVal lower as integer, ByVal upper as integer) As Integer
   
    Dim temp as integer
   
    If upper < lower then
        temp=upper
        upper=lower
        lower=temp
    End If
   
    Dim value   As integer
    Dim dist    As integer
   
    value=lower
    dist = Abs(lower-upper)
   
    Return ( Rnd(1)*dist) + value

End function
Title: Re: Tiny Future Composer Player for C/C++, FreeBasic and PureBasic
Post by: Shockwave on October 07, 2007
Here, use this and stop using out of date tinyptc library ;)

This one works well.




        #INCLUDE "TINYPTC_EXT.BI"
        #include  "tiny_fc.bi"
        #Include  "Windows.bi"

Const XRES=640
Const YRES=480
Const ARES=XRES*YRES

Dim Shared Buffer( ARES )
dim shared dummy as integer



initFC(0, @dummy, 0, "sample.fc")
startFC()


'-------------------------------------------------------------------------------
'       SET UP SCREEN;
'-------------------------------------------------------------------------------
       
        PTC_ALLOWCLOSE(0)
        PTC_SETDIALOG(0,"",0,0)   
       
        IF (PTC_OPEN("USE THIS FRAMEWORK",XRES,YRES)=0) THEN
        END-1
        END IF         

    WHILE(GETASYNCKEYSTATE(VK_ESCAPE)<>-32767) 

    ptc_update@buffer(0)

    Wend

    ptc_close()
    stopFC()
Title: Re: Tiny Future Composer Player for C/C++, FreeBasic and PureBasic
Post by: Rbz on October 09, 2007
Shockie is right, if you need to run something after your while/wend loop you must set ptc_allowclose(0) to disable internal tinyptc library escape key support.
Title: Re: Tiny Future Composer Player for C/C++, FreeBasic and PureBasic
Post by: RageSnax on May 14, 2008
Hi Slippy

thanks very much for a cool lib sorry it took so long to say so  :cheers: K++

RageSnax
Title: Re: Tiny Future Composer Player for C/C++, FreeBasic and PureBasic
Post by: abdulwaheed on November 01, 2010
Thanks for the helpful tip Smashing.