PSG music and game performance

페이지 1/3
| 2 | 3

By gacaffe

Supporter (14)

gacaffe의 아바타

03-10-2016, 12:02

Hi,

I've just registered to MRC. Great to see that the MSX community is so active!

I would like to compose PSG music for games. I would like to point out that I know how to program (C, assembly, etc.) but I do not have any experience with MSX programming. Back in the good old times I enjoyed a Philips VG-8235 and I was mad about the music of games like Knightmare, Zanac, etc.

I have two questions (sorry for the extension):
1. I am using Trilotraker and I can see that it is possible to set effects such as vibrato, which requires a continuous shift in frequency. This effects really make the most of the PSG but I think that they require to access the PSG chip more frequently than simply using the square waves with some volumen assigned, or the square waves with one of the available envelopes. My concern is if using the richer set of effects that TriloTracker provides will in any way reduce the performance of a game (number of sprites on screen, scrolling, computation of trajectories, etc).

I guess that the music is played through a periodic interrupt that reads the song "notes" and write in the PSG chip registers. Using sofisticated effects requires a higher interrupt frequency the native PSG effects. Can anyone tell me if there is a limit in the maximum frequency for the music interrupt? I know that this will depend on the kind of game, let's consider a very computing power demanding game like Nemesis.

2. How can I use the file that TriloTracker generates in a game? Is there a tutorial or examples in the forum/web?

To summarize, I would not like to compose something that eventually will not fit in any game because it is jeopardizing the performance of graphics, etc.

Thanks!

Login or 등록 to post comments

By ARTRAG

Enlighted (6276)

ARTRAG의 아바타

03-10-2016, 13:27

All parameters including frequencies are updated only in the isr so no extra CPU load for vibrato
Look for TriloTracker replayer on GitHub, it has examples and includes sfx support

By gacaffe

Supporter (14)

gacaffe의 아바타

03-10-2016, 15:24

Quote:

All parameters including frequencies are updated only in the isr so no extra CPU load for vibrato
Look for TriloTracker replayer on GitHub, it has examples and includes sfx support

Great, I will check that.

Many thanks

By NYYRIKKI

Enlighted (5396)

NYYRIKKI의 아바타

03-10-2016, 18:21

All PSG can do for free is to keep playing a note and on some case even fade it out without CPU involvement... Everything else takes some time from CPU... Changing note or volume takes about same time as writing a byte to VRAM... even calculating time "you don't do anything" takes a little time from each interrupt, but that is just normal. Practically all of the PSG tunes no matter if they are made with simple BASIC PLAY-commands or with Trilotracker type of advanced tools calculate their time consumption once in a screen refresh that means either 50 or 60 times a second depending of the machine's display frequency. Naturally doing more things means some more calculations & some more updates, but we are not talking about huge payload here. When you are playing a thing like vibrato the CPU updates some of the registers on each interrupt while playing without vibrato requires register updates maybe only once in 10 interrupts. This is not a big deal. The possibly gained extra time is even pretty hard for the game to use as it needs to consider anyway the "worst case scenario" where all the notes change at the same time.

Best way to get idea how much each player uses CPU time at different times is to patch the player routine so that it changes screen background color when it starts to handle music and then changes again when it finishes executing the play routines. Since the play routines are synced to screen refresh you will immediately see how much time was consumed from each screen draw by looking how thick block was drawn to screen. This is very old trick, but works still fine today. Smile

By gacaffe

Supporter (14)

gacaffe의 아바타

04-10-2016, 18:19

Nyyrikki,

Thanks a lot for your answer. I think that I have more than enough to check the effect on performance. And the trick about the screen refresh is nice. I use a similar trick when I want to check performance with my Dragon 64.

Right now, I am focused on composing, but at some point I will do some assembly coding.

Thanks again.

NYYRIKKI wrote:

All PSG can do for free is to keep playing a note and on some case even fade it out without CPU involvement... Everything else takes some time from CPU... Changing note or volume takes about same time as writing a byte to VRAM... even calculating time "you don't do anything" takes a little time from each interrupt, but that is just normal. Practically all of the PSG tunes no matter if they are made with simple BASIC PLAY-commands or with Trilotracker type of advanced tools calculate their time consumption once in a screen refresh that means either 50 or 60 times a second depending of the machine's display frequency. Naturally doing more things means some more calculations & some more updates, but we are not talking about huge payload here. When you are playing a thing like vibrato the CPU updates some of the registers on each interrupt while playing without vibrato requires register updates maybe only once in 10 interrupts. This is not a big deal. The possibly gained extra time is even pretty hard for the game to use as it needs to consider anyway the "worst case scenario" where all the notes change at the same time.

Best way to get idea how much each player uses CPU time at different times is to patch the player routine so that it changes screen background color when it starts to handle music and then changes again when it finishes executing the play routines. Since the play routines are synced to screen refresh you will immediately see how much time was consumed from each screen draw by looking how thick block was drawn to screen. This is very old trick, but works still fine today. Smile

By gacaffe

Supporter (14)

gacaffe의 아바타

04-10-2016, 18:19

ARTRAG wrote:

All parameters including frequencies are updated only in the isr so no extra CPU load for vibrato
Look for TriloTracker replayer on GitHub, it has examples and includes sfx support

Great, I will check that.

Many thanks

By gacaffe

Supporter (14)

gacaffe의 아바타

21-10-2016, 18:14

Well, I finish my first song:

https://www.youtube.com/watch?v=Br9bRLdzAPk

I composed the song using TriloTracker and only the PSG chip.
I hope you like it.

By hamlet

Scribe (2620)

hamlet의 아바타

21-10-2016, 18:25

Welcome gacaffe.
Hard to believe this should be only three channels.
Outstanding. I like to hear more!

By gacaffe

Supporter (14)

gacaffe의 아바타

21-10-2016, 19:04

hamlet wrote:

Welcome gacaffe.
Hard to believe this should be only three channels.
Outstanding. I like to hear more!

Thanks Hamlet! I am glad you liked it.

I explain in my YouTube channel what I had in mind when I wrote the song. After leaving behind my fears to hinder the performance of a game with too complex music, I decided to try to create the sensation of having more than 3 voices. So I am glad about your comment.
Basically I tried to have melodies "talking" to each other at different volumes, octave and, possibly, different volume envelopes all the time. For instance, in the same voice, I would play 3 notes with the same volume, and then, play another three notes with a different volume and octave (and evelope). I thought that this could create the impression that there were echoes, or even that there were more voices than 3. Also, I did "local" echoes, changing the volumes from one note to the next one in the same melody, so that, again, there would be an echo effect.
The main problem with this is that it is very hard to make changes once you have changed the volumes and octaves.

Later on, I realized that I made a big mistake with the envelopes that led to having lots of clicks, but it is difficult to hear, anyway Wink. I might improve this version, or I'll leave it for the next song.

Cheers!

By gacaffe

Supporter (14)

gacaffe의 아바타

11-06-2017, 10:43

A new song for PSG: https://youtu.be/oDgGsXCzbJ8

I still do not know much about instruments and drums, but having fun though.

By hit9918

Prophet (2868)

hit9918의 아바타

11-06-2017, 11:20

gacaffe change border color before call to tracker and after the call
and you got a realtime equalizer display of cpu usage

set border color
call player
set border color

when bars disappear in the border,
delay
set border color
call player
set border color
make the delay so big till the bar comes out on top border to see how fat it is

no more wondering, see cpu percent live.

it always is the vertical blank interrupt at monitor hz
adsr is the volume register updated at this rate
and vibrato and pitchslide is the frequency register updated at this rate

페이지 1/3
| 2 | 3