Shirus Tracker and PSG file format
Moderator: BigEvilCorporation
Shirus Tracker and PSG file format
Hello,
I am using Shiru's tracker to compose sound for my game.
The problem is the Tracker does not export in PSG file format.
How do I export in PSG ... since I need my compiler to run the tracks in PSG.
Awaiting A Reply.
I am using Shiru's tracker to compose sound for my game.
The problem is the Tracker does not export in PSG file format.
How do I export in PSG ... since I need my compiler to run the tracks in PSG.
Awaiting A Reply.
tinctu:
The Mod2PSG2 tracker I can use the Basi code to play music composed in this Tracker ?
So I can only use Shiru's tracker if I can program in Assembly. Which I obvioulsy can't.
mic_:
I don't understand what you mean it is French to me
Shiru:
I want to confirm if I compose music in your tracker I can use it provided I can code Motorolla Assembly or Z80 Assembly to playback music in the game.
By the way I'm using the Basi compiler.
The Mod2PSG2 tracker I can use the Basi code to play music composed in this Tracker ?
So I can only use Shiru's tracker if I can program in Assembly. Which I obvioulsy can't.
mic_:
I don't understand what you mean it is French to me
Shiru:
I want to confirm if I compose music in your tracker I can use it provided I can code Motorolla Assembly or Z80 Assembly to playback music in the game.
By the way I'm using the Basi compiler.
SHIRU YOU ARE A PROGRAMMING GOD !!!
THANK YOU THANK YOU !!! ))
I thought I would have to write an engine in Assembly but you already made the engine .
THANK YOU THANK YOU !!! ))
'Simple replayer for TFD files exported from TFM Music Maker
'Pure BEX version by Shiru, 31.12.07
'How to use:
' Load your music module into editor, File->Export->TFD file for SMD.
' Now you can use resulted file with this replayer. File can be large
' because no compression used, usually it has size from tens up to
' hundreds of KB, depending from music module (more slides and volume
' effects - larger module)
cls
ink 1
locate 1,1
print "TFD music replayer"
reload musicData 'point to music data (needed only once, right before init)
gosub tfdPlayInit 'init replayer
on VBLANK gosub tfdPlayFrame
enable INTERRUPTVBLANK
mainLoop:
sleep 1 'main loop of your program
goto mainLoop
'Replayer init. Set data read pointer to music data (by RELOAD or RESTORE)
'and GOSUB here. It needed once before playing
tfdPlayInit:
DataPtr&=DataPtr&()+4 'skip TFMD signature
for a=1 to 3 'skip three null-terminated text lines
while 1
read b
if b=0 then exit while
wend
next
vTfdDataPtr&=DataPtr&() 'store current read position
vTfdLoopPtr&=vTfdDataPtr& 'default loop position
vTfdCurrentBank=0 'select bank0
vTfdFrameCnt=0 'frame counter
vTfdWaitCnt=0 'wait counter
pokeint &hA11100,&h100 'busreq on
pokeint &hA11200,&h100 'reset Z80 and YM2612
pokeint &hA11200,0
pokeint &hA11100,0 'busreq off
return
'Replayer update. GOSUB here each frame (1/50sec) to play music.
'Note that for NTSC system you must do speed compensation to
'make music play at normal speed. In this example that done
'simply by skipping every 6th frame
tfdPlayFrame:
vTfdFrameCnt++ 'increment frame counter
if TvType()=0 then 'speed compensation for NTSC
if vTfdFrameCnt%6=0 then return
endif
if vTfdWaitCnt then 'skip frames if needed
vTfdWaitCnt--
else
vTfdDataTemp&=DataPtr&() 'store current read position
DataPtr&=vTfdDataPtr& 'set read position of music data
while 1
read vTag
if vTag<&hFA then 'write to YM2612 register
read vData 'read data
if vTag<&h30 then
curBank=0 'writes below 0x30 always goes to bank0
else
curBank=vTfdCurrentBank
endif
adrReg&=&hA04000+curBank
adrVal&=&hA04001+curBank
if vTag=&h28 then 'correction for bank1 Key On/Off event
if vTfdCurrentBank then
vData=vData+4
endif
endif
'pokeint &hA11100,&h0100 'busreq on
while peek(&hA04000).7 'wait for busy
wend
poke adrReg&,vTag 'write YM2612 register number
while peek(&hA04000).7 'wait for busy
wend
poke adrVal&,vData 'write YM2612 register data
'pokeint &hA11100,&h0000 'busreq off
elseif vTag=&hFF then 'single frame
vTfdCurrentBank=0
exit while
elseif vTag=&hFE then 'few frames
vTfdCurrentBank=0
read vTfdWaitCnt
vTfdWaitCnt=vTfdWaitCnt+2
exit while
elseif vTag=&hFD then 'select bank1
vTfdCurrentBank=2
elseif vTag=&hFC then 'select bank0
vTfdCurrentBank=0
elseif vTag=&hFB then 'end of data
DataPtr&=vTfdLoopPtr& 'jump to loop position
elseif vTag=&hFA then 'loop position
vTfdLoopPtr&=DataPtr&() 'remember read position
endif
wend
vTfdDataPtr&=DataPtr&() 'store read position of music data
DataPtr&=vTfdDataTemp& 'restore current read position
endif
return
musicData:
datafile music.tfd,BIN
THANK YOU THANK YOU !!! ))
I thought I would have to write an engine in Assembly but you already made the engine .
THANK YOU THANK YOU !!! ))
'Simple replayer for TFD files exported from TFM Music Maker
'Pure BEX version by Shiru, 31.12.07
'How to use:
' Load your music module into editor, File->Export->TFD file for SMD.
' Now you can use resulted file with this replayer. File can be large
' because no compression used, usually it has size from tens up to
' hundreds of KB, depending from music module (more slides and volume
' effects - larger module)
cls
ink 1
locate 1,1
print "TFD music replayer"
reload musicData 'point to music data (needed only once, right before init)
gosub tfdPlayInit 'init replayer
on VBLANK gosub tfdPlayFrame
enable INTERRUPTVBLANK
mainLoop:
sleep 1 'main loop of your program
goto mainLoop
'Replayer init. Set data read pointer to music data (by RELOAD or RESTORE)
'and GOSUB here. It needed once before playing
tfdPlayInit:
DataPtr&=DataPtr&()+4 'skip TFMD signature
for a=1 to 3 'skip three null-terminated text lines
while 1
read b
if b=0 then exit while
wend
next
vTfdDataPtr&=DataPtr&() 'store current read position
vTfdLoopPtr&=vTfdDataPtr& 'default loop position
vTfdCurrentBank=0 'select bank0
vTfdFrameCnt=0 'frame counter
vTfdWaitCnt=0 'wait counter
pokeint &hA11100,&h100 'busreq on
pokeint &hA11200,&h100 'reset Z80 and YM2612
pokeint &hA11200,0
pokeint &hA11100,0 'busreq off
return
'Replayer update. GOSUB here each frame (1/50sec) to play music.
'Note that for NTSC system you must do speed compensation to
'make music play at normal speed. In this example that done
'simply by skipping every 6th frame
tfdPlayFrame:
vTfdFrameCnt++ 'increment frame counter
if TvType()=0 then 'speed compensation for NTSC
if vTfdFrameCnt%6=0 then return
endif
if vTfdWaitCnt then 'skip frames if needed
vTfdWaitCnt--
else
vTfdDataTemp&=DataPtr&() 'store current read position
DataPtr&=vTfdDataPtr& 'set read position of music data
while 1
read vTag
if vTag<&hFA then 'write to YM2612 register
read vData 'read data
if vTag<&h30 then
curBank=0 'writes below 0x30 always goes to bank0
else
curBank=vTfdCurrentBank
endif
adrReg&=&hA04000+curBank
adrVal&=&hA04001+curBank
if vTag=&h28 then 'correction for bank1 Key On/Off event
if vTfdCurrentBank then
vData=vData+4
endif
endif
'pokeint &hA11100,&h0100 'busreq on
while peek(&hA04000).7 'wait for busy
wend
poke adrReg&,vTag 'write YM2612 register number
while peek(&hA04000).7 'wait for busy
wend
poke adrVal&,vData 'write YM2612 register data
'pokeint &hA11100,&h0000 'busreq off
elseif vTag=&hFF then 'single frame
vTfdCurrentBank=0
exit while
elseif vTag=&hFE then 'few frames
vTfdCurrentBank=0
read vTfdWaitCnt
vTfdWaitCnt=vTfdWaitCnt+2
exit while
elseif vTag=&hFD then 'select bank1
vTfdCurrentBank=2
elseif vTag=&hFC then 'select bank0
vTfdCurrentBank=0
elseif vTag=&hFB then 'end of data
DataPtr&=vTfdLoopPtr& 'jump to loop position
elseif vTag=&hFA then 'loop position
vTfdLoopPtr&=DataPtr&() 'remember read position
endif
wend
vTfdDataPtr&=DataPtr&() 'store read position of music data
DataPtr&=vTfdDataTemp& 'restore current read position
endif
return
musicData:
datafile music.tfd,BIN
Shiru one last question for Sound FX.
If I take a wave file like a "Womans Scream" can I convert it to PSG and play it back using this:
psgvol 0,15
psg 3,1
psgvol 3,12
while 1
for a=200 to 1000 step 20
psg 0,a
sleep 1
next
for a=800 to 200 step -20
psg 0,a
sleep 1
next
wend
Or can I play the wav sound directly ?
If I take a wave file like a "Womans Scream" can I convert it to PSG and play it back using this:
psgvol 0,15
psg 3,1
psgvol 3,12
while 1
for a=200 to 1000 step 20
psg 0,a
sleep 1
next
for a=800 to 200 step -20
psg 0,a
sleep 1
next
wend
Or can I play the wav sound directly ?
You can't convert WAV to PSG or FM. WAV is digitized sample, PSG and FM are synthesizers. You'd better to learn the basics before thinking about sound or making a game.
To play sample, you have to stream it at constant rate to DAC, in case with SMD it is one of channels of YM2612 (DAC mode replaces one of FM channels). If you want to play FM music at the same time, you should make special driver for this.
To play sample, you have to stream it at constant rate to DAC, in case with SMD it is one of channels of YM2612 (DAC mode replaces one of FM channels). If you want to play FM music at the same time, you should make special driver for this.
I don't know if BEX has built-in driver for sample playing, but even if it has, it can't work with music player, because they both should have access to YM2612, and they will conflict. Thus you need custom sample player.
Simplest (and surely not the best) solution is to have sample player on Z80 side, and music player on M68K side, and when music player should access to YM2612, it should stop Z80 first, and before re-enabling Z80 it should select DAC register of YM2612.
Simplest (and surely not the best) solution is to have sample player on Z80 side, and music player on M68K side, and when music player should access to YM2612, it should stop Z80 first, and before re-enabling Z80 it should select DAC register of YM2612.
Yes Shiru !
You are right like Golden Axe.
In Golden Axe the music plays and when the sample has to play the M68K sound goes silent and then the Z80 plays a sample.
I see what you mean.
But what I don't understand is why have not all these great programmers who have produced all these excellent tools for Sega game programming not made a tool for playing samples ?
This confuses me!
Why Shiru Why ?
You are right like Golden Axe.
In Golden Axe the music plays and when the sample has to play the M68K sound goes silent and then the Z80 plays a sample.
I see what you mean.
But what I don't understand is why have not all these great programmers who have produced all these excellent tools for Sega game programming not made a tool for playing samples ?
This confuses me!
Why Shiru Why ?