Dark Bit Factory & Gravity
PROGRAMMING => Freebasic => Topic started by: Rbz on December 20, 2008
-
Freebasic tinyptc extended++
----------------------------
Standard ptc functions:
-----------------------
ptc_open
ptc_update
ptc_close
Tinyptc extension functions:
----------------------------
ptc_setflip
ptc_getmousex
ptc_getmousey
ptc_getleftbutton
ptc_getrightbutton
ptc_setdialog
ptc_allowclose
ptc_getwindow
ptc_setmousewheel
ptc_getmousewheel
Including ufmod ver.1.25.2a:
----------------------------
uFMOD_PlaySong
uFMOD_StopSong
uFMOD_Pause
uFMOD_Resume
uFMOD_GetStats
uFMOD_GetTime
uFMOD_GetTitle
uFMOD_SetVolume
uFMOD_Jump2Pattern
uFMOD_Rewind()
Sound FX player:
----------------
sndfx_init()
sndfx_load(byval as any ptr, byval samplesize as integer, byval samplenum as integer) as integer
sndfx_play(byval samplenum as integer, byval smploop as integer) as integer
sndfx_stop(byval samplenum as integer) as integer
sndfx_setvolume(byval samplenum as integer, byval volume as integer) as integer
sndfx_release()
To install:
-----------
From "tinyptc_ext++.zip" file extract and copy the new tinyptc_ext++ library
( libtinyptc_ext++.a and libmmx.a) to the freebasic install folder:
Ex.: C:\FreeBasic\lib\win32
And "tinyptc_ext++.bi" to the folder C:\FreeBasic\inc
Check out examples test folder
This version was designed for people who had troubles adding .xm song to their intros using ufmod, which I admit is a bit annoying to compile, this new library includes the latest ufmod library (1.25.2a) + tinyptc_ext in one file, making newbies life a bit easy.
In the examples folder you will find one example to load song from memory and from file and plus an image loader routine.
-
thanx man :cheers:
i'll go test it right now :stirrer:
EDIT: okies i've installed as instructed and i get these results:
result 1 with this command #Include Once "tinyptc.bi"
the code
Screenres 640,480,16,2
#Include Once "tinyptc.bi"
#include "windows.bi"
#include "ufmod.bi"
#include "tune.bas"
#include "crt.bi"
Dim hWave As HWAVEOUT
hWave = uFMOD_PlaySong(@Music(0),31009,XM_MEMORY)
the tune.bas
'// Created with Bin2Bas V0.22 - by Rbraz (c) 2006
dim shared music(0 to 31009) as ubyte = { _
&H45,&H78,&H74,&H65,&H6E,&H64,&
and the error
Compiler output:
C:\Program Files\FreeBASIC\FBIDETEMP.o:fake:(.text+0x51): undefined reference to `uFMOD_PlaySong@12'
result 2 using #Include Once "tinyptc_ext++.bi" , same code and tune.bas file as above
Compiler output:
C:/Program Files/FreeBASIC/ufmod.bi(45) error 4: Duplicated definition
declare function uFMOD_PlaySong stdcall alias "uFMOD_PlaySong" (byval as LPVOID , byval as DWORD, byval as DWORD) as HWAVEOUT
^
C:/Program Files/FreeBASIC/ufmod.bi(51) error 4: Duplicated definition
declare sub uFMOD_Pause stdcall alias "uFMOD_Pause" ()
^
C:/Program Files/FreeBASIC/ufmod.bi(54) error 4: Duplicated definition
declare sub uFMOD_Resume stdcall alias "uFMOD_Resume" ()
^
C:/Program Files/FreeBASIC/ufmod.bi(63) error 4: Duplicated definition
declare function uFMOD_GetStats stdcall alias "uFMOD_GetStats" () as UINTEGER
^
C:/Program Files/FreeBASIC/ufmod.bi(71) error 4: Duplicated definition
declare function uFMOD_GetTime stdcall alias "uFMOD_GetTime" () as UINTEGER
^
C:/Program Files/FreeBASIC/ufmod.bi(78) error 4: Duplicated definition
declare function uFMOD_GetTitle stdcall alias "uFMOD_GetTitle" () as ZSTRING ptr
^
C:/Program Files/FreeBASIC/ufmod.bi(87) error 4: Duplicated definition
declare sub uFMOD_SetVolume stdcall alias "uFMOD_SetVolume" (byval as DWORD)
^
Results:
Compilation failed
-
work GREAT ;D Excellent Library 8) 8) 8)
-
@bikerboy: Use the source code example from the examples folder, your old source code won't work anymore.
-
Screenres 640,480,16,2
#Include Once "tinyptc_ext++.bi"
'#Include Once "tinyptc.bi"
#include "windows.bi"
#include "ufmod.bi"
#include "tune.bas"
#include "crt.bi"
'Play our music
Dim hWave As HWAVEOUT
hWave = uFMOD_PlaySong(@Music(0),31009,XM_MEMORY)
'Main loop
while(GetAsyncKeyState(VK_ESCAPE)<>-32767)
for x = 0 to 320
for y = 0 to 240
buffer(x+(y*XRES)) = image(x+(y*320))
next
next
ptc_update(@buffer(0))
erase buffer
wend
'Stop playing
uFMOD_StopSong()
'// Created with Bin2Bas V0.22 - by Rbraz (c) 2006
dim shared Music(0 to 31009) as ubyte = { _
&H45,&H78,&H74,&H65,
Compiler output:
C:/Program Files/FreeBASIC/ufmod.bi(45) error 4: Duplicated definition
declare function uFMOD_PlaySong stdcall alias "uFMOD_PlaySong" (byval as LPVOID , byval as DWORD, byval as DWORD) as HWAVEOUT
^
C:/Program Files/FreeBASIC/ufmod.bi(51) error 4: Duplicated definition
declare sub uFMOD_Pause stdcall alias "uFMOD_Pause" ()
^
C:/Program Files/FreeBASIC/ufmod.bi(54) error 4: Duplicated definition
declare sub uFMOD_Resume stdcall alias "uFMOD_Resume" ()
^
C:/Program Files/FreeBASIC/ufmod.bi(63) error 4: Duplicated definition
declare function uFMOD_GetStats stdcall alias "uFMOD_GetStats" () as UINTEGER
^
C:/Program Files/FreeBASIC/ufmod.bi(71) error 4: Duplicated definition
declare function uFMOD_GetTime stdcall alias "uFMOD_GetTime" () as UINTEGER
^
C:/Program Files/FreeBASIC/ufmod.bi(78) error 4: Duplicated definition
declare function uFMOD_GetTitle stdcall alias "uFMOD_GetTitle" () as ZSTRING ptr
^
C:/Program Files/FreeBASIC/ufmod.bi(87) error 4: Duplicated definition
declare sub uFMOD_SetVolume stdcall alias "uFMOD_SetVolume" (byval as DWORD)
^
C:/Program Files/FreeBASIC/FBIDETEMP.bas(19) error 67: Array not dimensioned, before '('
buffer(x+(y*XRES)) = image(x+(y*320))
^
C:/Program Files/FreeBASIC/FBIDETEMP.bas(19) warning 12(0): Implicit variable allocation, image
C:/Program Files/FreeBASIC/FBIDETEMP.bas(23) error 67: Array not dimensioned, before '('
ptc_update(@buffer(0))
^
C:/Program Files/FreeBASIC/FBIDETEMP.bas(25) error 59: Expected array
erase buffer
^
C:/Program Files/FreeBASIC/FBIDETEMP.bas(25) error 123: Too many errors, exiting
Results:
Compilation failed
:skint:
Ps.i have every file in the same folder
EDIT: just commented '#include "ufmod.bi" and it compiles just fine but no sound :skint:
EDIT3: lol my n00bness is unlimited :P
i had '#include "ufmod.bi" that's why there was no bling bling :P
works perfect now ;D
thanx again man :cheers:
question, is this method still valid for putting the bas file into the exe one? -> fbc -s console ufmod.o your_intro_name.bas
EDIT4: :o lol
yup it was a dump question it works perfectly :D
-
Hey Rbz, you rock :)
-
hey guys i think i have a problem (as usual ::))
the music plays just fine and it compiles and everything , but ...
the song plays only once and then pure silence, is there a command to add or something to make it start again once it's finished?
-
Had no idea there were 2 different versions available of TinyPTC_Ext.
I have been using the download from the other post without UFmod included, as I only need for now PTC_Ext.
o_O
-
And did you find it useful ?
-
I've used the other tinyptc_ext topic download link for ages, and its extremely usefull.
With this one tinyptc_ext++, I am not sure if this is exactly the same as the one im currently using plus the added bonus of ufmod, or if the tinyptc parts are totally different.
I do know one thing mind, if you use this one ( ext++.bi ) it clashes with Bass.
So I am presuming that the other sticky has an identical ptc_ext. just the ++ means its got UFMOD thrown in with it.
I may of answered my own question above, lack of sleep :)
Cheers,
Clyde.
-
If you need to be analysing sound channel data etc I find that minifmod works really well with this version of tinyptc.
-
So is this an entirely new version update of tinyptc_ext?
or is it that it's the same version but with the added support of UFmod?
Thanks.
-
Yes.
Jim.
The latter.
-
...
or is it that it's the same version but with the added support of UFmod?
...
Yes, the idea is to make it easy for newcomers to use ufmod library on their projects.
-
Ok cool, thanks for clarifying.
Just remember anyone using this version which is #include "tinyptc_ext++.bi" that if you want to use bass.bi for a change, you'll need to download and use the standalone tinyptc_ext.bi in the other sticky, as it will clash with ufmod.
-
Clyde, it does work with bass, just need some changes in the bass.bi, I've attached one example here that uses ufmod and bass.
The dude who have converted bass.bi used some mmsystem.bi defines on it's file which clash with another library using mmsytem.bi like tinyptc++.
-
Thanks kindly rbz.
Cheers your ex partner is crime,
Clyde.
-
Great work!
Thank a lot1!
-
Welcome to the forum Mountiho :)
-
Thanks for this! It has enabled me to get up and running very quickly and is absolutely ideal for retro remaking :)
cheers
-
It would be really good to be able to play one of the samples from the mod "ad hoc".
There's a lot of remakes that require a single SFX. I guess the playing of any SFX would be required to be added here, as the mixing of the sound buffer is done here.
Also, any games using music + SFX will need this.
I might be tempted to start looking at a game with TinyPTC with this feature :)
-
Hi Nzo, do you mean a .wav sample or .mp3 ?
I tried to find this module "ad hoc" without any success, I'm an amiga noobzor :P
-
I mean, play any of the samples in the module (sample 1, sample 2 etc.) as a sound fx.
Ad hoc in this case would be better described at wikipedia :)
-
Oh, hehe, it's Latin phrase ;D
Ok, I'll take a look at it :)
-
@Nzo: Check this out, I've added some sound fx functions.
Not really playing samples from xm file, as I've noticed that in some musics those samples are almost useless because note/pitch.
Instead I've made it play any ".wav" file simultaneously, you can load from memory or open a file.
There's an example included to show how to load from memory or file, press F1 or F2 to play samples while playing a music.
Enjoy :)
{Edited - tinyptc_ext++ now have sound fx replayer}
-
That appears to be spot on!
Thanks a lot - will be very useful :)
-
Updated:
+ Added sound fx to tinyptc_ext++
- Removed an "unwanted feature" (bug :)) on windowed mode.
-
I really like the sound capabilities of this lib!
Playing samples is childs play with this now. It's really kickass.
-
Any chance of an update to the original tinyptc_ext for the window mode bug? As I often use minifmod and others for music playback out of personal choice.
Cheers!
-
Already done: ;)
http://www.dbfinteractive.com/forum/index.php?topic=1382.0 (http://www.dbfinteractive.com/forum/index.php?topic=1382.0)
-
Hi, just registered here....
-
Welcome.