It is currently Thu Nov 15, 2018 12:49 pm

All times are UTC - 7 hours





Post new topic Reply to topic  [ 21 posts ]  Go to page 1, 2  Next
Author Message
PostPosted: Fri Sep 14, 2018 8:53 pm 
Offline
User avatar

Joined: Tue Jun 24, 2008 8:38 pm
Posts: 2041
Location: Fukuoka, Japan
I'm not sure if they are issues or not so before digging into a codebase that I don't know to find a problem that may not be one, I should first ask if other people encountered the issue.

1) The first issue I encountered is while playing songs. In general it works fine but depending which song is played first, the result is different. For example, song A always work fine. Song B works fine after song A. If song B is played first, it's like some channel are not "active" yet.

Inside Famitracker the song is fine but not with the driver. If a sound fx is played then the channel works. Maybe it's a envelop not set thing, I'm not sure yet.

2) Another issue but I need to re-test in what situation, if the song comes to an end by itself, some issues occur. I forgot if sfx don't work anymore or the next song is affected. I will retest and update that issue later.

3) Last one, the issue I had with more than 256 bytes, if I play manually both channel at the same time it actually works but when a song is actually playing, sometime the sfx is not played properly. If no music, it always works fine, which give me the impression that this issue could happen with other sfx in the future.

Those are the issues I have and that I need to investigate the cause. For sfx, when I first tried to do it myself with driver 3.0, I remember modifying the famitracker driver to "stop" a channel from playing. I had a binary mask that told which channel should be stopped. I think the current example from Shiru may not be doing that and just put data of SFX over music data, which could be the cause of #3. I will try to dug up the code I did to retry to stop a channel that way but I'm not sure if the current famitone sfx driver is aware "when" a sfx finish. If not, I won't be able to re-use that way of stopping channel.

Thank you for any information on the subject.


Top
 Profile  
 
PostPosted: Sat Sep 15, 2018 5:30 am 
Offline
User avatar

Joined: Sat Aug 15, 2015 3:42 pm
Posts: 150
Location: France
At the end of this topic, I posted some modification for the famitracker/famitone-sfx combo that may help some of your issues. I don't know if you already apply them ?

For #1, make sure your instrument are correctly initialized at the beginning of the track in famitracker.

Hope it helps :)

_________________
My first game : Twin Dragons available at Broke Studio.


Top
 Profile  
 
PostPosted: Sat Sep 15, 2018 5:46 am 
Offline
User avatar

Joined: Fri May 08, 2015 7:17 pm
Posts: 2331
Location: DIGDUG
Quote:
If song B is played first, it's like some channel are not "active" yet.


I had this same problem on Vigilante Ninja 2. It only affected 1 channel of 1 song, and it only happened sometimes.

I never figured out how to fix it. After a few seconds the channel did start working correctly.

Quote:
make sure your instrument are correctly initialized at the beginning of the track


Hmm, do you think re initializing the music before changing songs might have fixed it?

_________________
nesdoug.com -- blog/tutorial on programming for the NES


Top
 Profile  
 
PostPosted: Sat Sep 15, 2018 8:57 am 
Offline
User avatar

Joined: Tue Jun 24, 2008 8:38 pm
Posts: 2041
Location: Fukuoka, Japan
@glutock

This was my guess that something was missing in the song but since I'm not the one that made them I don't know much about the details ^^;; I will check them, just in case.

But the bug mostly happen if I ask the game to skip parts to test. If it start from the beginning, the first song fixes everything. Still, I should check.

One of them was that it changed the "tone" (forgot the name", V00 something) of the noise channel, affecting the rest. I just added back something extra at the end and everything was fine. I think I will need to review the songs, just in case.

I will check your topic. The thing I'm concerned the most is sfx that may not play properly, maybe that topic talks about it.

edit:

dougeff wrote:
Hmm, do you think re initializing the music before changing songs might have fixed it?


I don't think it would fix it. I separated my songs as 1 file per song and re-init on every state and the problem occurred. It is more like the song is missing something that inside the editor is not an issue.

edit2:

@glutock

I did a quick check and didn't know this topic. I will apply to changes to my current build and see how it goes. What I would like to know is if you had issues where sfx didn't play as expected. It feels like the music channel is not stopped when the sfx play and causes issue. I could be wrong but that's one possibility.

One SFX is bigger than 256 bytes. Since it uses 2 channels, I decided to create 2 sfx and play them at the same time (technically not true but you know what I mean :)). It's erratic so I'm tempted to try update the engine to allows bigger since with the example given by rainwarrior but there is a chance that this issue will persist.

Will test the update and update this thread if it did improve my issues. Thanks again! Merci beaucoup!


Top
 Profile  
 
PostPosted: Sat Sep 15, 2018 10:00 am 
Offline
User avatar

Joined: Sat Aug 15, 2015 3:42 pm
Posts: 150
Location: France
dougeff wrote:
Hmm, do you think re initializing the music before changing songs might have fixed it?


I don't think so since the init/load routines only resets vars and init pointers. But it can't hurt.

I just compared my version of the famitracker/famitone combo and the one on Shiru's website and they're a bit different.
I'll try to clean my code and share it here if you're interested.

_________________
My first game : Twin Dragons available at Broke Studio.


Top
 Profile  
 
PostPosted: Sat Sep 15, 2018 10:03 am 
Offline
User avatar

Joined: Tue Jun 24, 2008 8:38 pm
Posts: 2041
Location: Fukuoka, Japan
Yes, very interested ;) I want to do a diff and see what has changed.


Top
 Profile  
 
PostPosted: Sat Sep 15, 2018 10:37 am 
Offline
User avatar

Joined: Sat Aug 15, 2015 3:42 pm
Posts: 150
Location: France
So I took Shiru's example on his website, add updated his code with what I've done for Twin Dragons.
This may not be perfect, but I never heard any music/sfx glitches in the game so far.

Hope it helps :)


Attachments:
shiru-ft-sfx.zip [96.87 KiB]
Downloaded 47 times

_________________
My first game : Twin Dragons available at Broke Studio.
Top
 Profile  
 
PostPosted: Sat Sep 15, 2018 11:30 am 
Offline
User avatar

Joined: Tue Jun 24, 2008 8:38 pm
Posts: 2041
Location: Fukuoka, Japan
I see, thanks!

I applied the modifications you mentioned on NA already so I will do a diff to see if anything else is missing. Maybe my issue is just the way I'm using it in the hope to avoid modifying for more than 256 bytes causes an issue. Sometime it works fine, sometime it doesn't. Maybe it's a concurrency issue since I'm setting 2 effects that I really want to be run at the same time and it may get out of sync. Will do a few tests about that.

If I find anything later on the subject I will share it.


Top
 Profile  
 
PostPosted: Sat Sep 15, 2018 1:41 pm 
Offline
User avatar

Joined: Sun Jan 22, 2012 12:03 pm
Posts: 6950
Location: Canada
dougeff wrote:
Quote:
If song B is played first, it's like some channel are not "active" yet.


I had this same problem on Vigilante Ninja 2. It only affected 1 channel of 1 song, and it only happened sometimes.

I never figured out how to fix it. After a few seconds the channel did start working correctly.

Quote:
make sure your instrument are correctly initialized at the beginning of the track


Hmm, do you think re initializing the music before changing songs might have fixed it?

I've found pausing to be a problem generically with album compilations, which might be a similar problem.

I a 2A03 chanel is halted by a 0 bit in $4015, or length counter running out, both cases will reset the length counter to 0, and the channel won't start producing sound again until the high frequency register is written again to reload the length counter. (Silencing with volume 0 doesn't have this problem.) So a symptom of this, is that if "pause" is setting $4015 to 0, after resuming the square/triangle channels won't turn back on until the music code knows to write the high byte again (depends when A-3/A-2/A-1 is crossed in the music next). Normally Famitracker won't write to that high byte unless it knows its changed (since it causes a phase reset pop otherwise).

So if your SFX have use of the length counter (probably not?) or write to $4015 (maybe? is there a C00 getting picked up?) this might describe your problem.


Top
 Profile  
 
PostPosted: Sat Sep 15, 2018 8:54 pm 
Offline
User avatar

Joined: Tue Jun 24, 2008 8:38 pm
Posts: 2041
Location: Fukuoka, Japan
@glutock

Did you modify the ft_driver in any way to fix issues? I just did a very quick review of the code (still need to do a deeper one when the kids will be sleeping..) and there is extra code that I don't have in the effect section and other places. Some of the update you mentioned on NA (to skip checking song stop in ft_music_play but to check instead in update) is not done so I'm not sure what is important or not ^^;;;

Once I check in more details your current driver I may have some question on the subject. I could blindly just add the code but usually I don't find that appropriate.


Top
 Profile  
 
PostPosted: Sun Sep 16, 2018 1:10 am 
Offline
User avatar

Joined: Sat Aug 15, 2015 3:42 pm
Posts: 150
Location: France
My guess is that Shiru didn't use the last version at the time. That may explain the differences in the effect section for example, and other places.

I forgot some changes, so here's the updated version in attachement. Should be right this time.
It doesn't 100% match what I said on the NA topic, because I made other changes for Twin Dragons.

Also this might help :
Code:
var_PlayerFlags
; t------p
; t : 0 - playing / 1 - stop
; p : 0 - playing / 1 - pause


Attachments:
shiru-ft-sfx.zip [136.72 KiB]
Downloaded 47 times

_________________
My first game : Twin Dragons available at Broke Studio.
Top
 Profile  
 
PostPosted: Sun Sep 16, 2018 7:15 am 
Offline
User avatar

Joined: Tue Jun 24, 2008 8:38 pm
Posts: 2041
Location: Fukuoka, Japan
Depending when he tested it then yes, it could have been the reason for the differences. I didn't follow the driver since 3.0 so I'm not much aware of what happened these days ^^;;;

As for the flag, is it something you changed or it was already like that? So when $00 then playing but if $01 then it's means pause and if $80 means stop.

Thank you again for sharing your modifications, I really appreciate it!

edit:

I just finished the merge with your driver and it's working except now the music is a lot faster, like it's running for pal or something? ^^;; Is it possible that the $80 modification cause the ntsc/pal setting to be different? That's my only guess for now.

edit2:

The change to $80 had an issue with another place in my own code and I fixed it.

I took your sample and tested the affected sfx with the song that had issue. In your version, the dual channel sfx split in 2 for avoiding size limit is actually working "but" sfx doesn't stop the channel while the sfx is playing so in the middle of the sfx playing you still have some part of the song playing, which feels odd/broken. So something is different from the version I used to start my code and your version. For 1 channel sfx, it doesn't seems to cause much issue. I guess by looking at both of them I should be able to figure a solution that fix my issue. Long time ago, with ft3.0, what I was doing is stopping the data to be put in that channel with a flag, so the channel was stopped until the sfx was over but it seems that the famitone way "mix" the music and sfx when possible, even thought the sfx is not finished yet.

I will try to figure out something out of it.


Top
 Profile  
 
PostPosted: Tue Sep 18, 2018 11:47 am 
Offline
User avatar

Joined: Sat Aug 15, 2015 3:42 pm
Posts: 150
Location: France
Sorry for not answering sooner.

The PAL/NTSC check may be wrong. Depending on your region detection routine, you may have to change this part (in init.s and the famitone part).

I don't remember why exactly I modified the "var_PlayerFlags" flag, maybe something specific in my game where I wanted to know if the music was paused or stopped. Don't know :(

I never used oversized sfx, how did you do that ?
Feel free to send me a song and sfx so I can test it.

_________________
My first game : Twin Dragons available at Broke Studio.


Top
 Profile  
 
PostPosted: Tue Sep 18, 2018 6:34 pm 
Offline
User avatar

Joined: Tue Jun 24, 2008 8:38 pm
Posts: 2041
Location: Fukuoka, Japan
Don't worry! Every one is busy and this is one of my many issues on my todo list ;)

For Pal/NTSC, I found the issue so everything is fine. For now I do not support both for my current testing but eventually may so. For the flag, well, as long that it works, I'm fine with it :lol: The only difference left that I need to figure out later is the way that the data is fed to the register is completely different than the version I have. This may be one of the reason why the effects works fine in your version but "may" cause possible issue in the song played (IF the sfx is not the issue in the first place) but in my version, the sfx played is wrong but the music seems fine. Since I adapted the code to remove it from neslib/crt-nmi, I would need to create a sample with my own code (I can do it later if required).

I included a sample of your code with my own makeFile. The files are organised so the makeFile can compile any files you sent to it without editing it in any folder/sub folder in src (very useful for quick testing). The cfg was adapted for cc65 2.17 and the necessary files for creating the runtime.lib are included too. The data folder contains some sample music from a well known game and with some sfx to reproduce the possible error. The FTM are included too since I'm not the one that made then anyway (very nice music and sfx by the way!).

You will see that the music channel 1/2 doesn't start at the beginning. This is not specific to your version but a problem in general. Since I did not make the song, I don't know what cause it after checking the ftm ^^;;; But this is not the issue at hand. After playing a few time the channel 1/2 should work now that they are activated. If you play sfx with left pad, 2 sfx are played at the same time. If you listen carefully while trying a few time, you will see that the song channel 1/2 are still playing to some degree while the SFX is playing. I would expect the song data to be completely stopped until the sfx is finished playing (unless the driver was updated to mix both at the same time).

As for bigger than 256 bytes, I didn't implement/test yet: for now, I'm avoiding the issue by "splitting" a multi-channel sfx in 2 sfx and playing them at the same time. It seems to be doable, except for the song still playing issue.

If you cannot compile because of lack of make environment, an already compiled nes file is included.


Attachments:
shiru-ft-sfx-issue.zip [317.14 KiB]
Downloaded 48 times
Top
 Profile  
 
PostPosted: Tue Sep 18, 2018 11:06 pm 
Offline
User avatar

Joined: Sat Aug 15, 2015 3:42 pm
Posts: 150
Location: France
Just tested the rom for now, and it seems that you can't play sfx before playing a song.
I don't know if it helps, but in my init code I have this :

Code:
    ; initialize sound APU
    ldx #$00
apu_clear_loop:
    sta $4000, X            ; write 0 to most APU registers
    inx
    cpx #$13
    bne apu_clear_loop
    ldx #$00
    stx $4015               ; turn off square/noise/triangle/DPCM channels

    ; acknowledge/disable both APU IRQs
    ; (frame counter and DMC completion)
    lda #$40
    sta $4017  ; APU IRQ: OFF!
    lda $4015  ; APU IRQ: ACK!

    ; enable all channels but DPCM
    lda #$0F
    sta $4015

    ;previous pulse period MSB, to not write it when not changed
    lda #$ff
    sta PREV_4003
    sta PREV_4007

    ; stop music
    lda #$80
    sta var_PlayerFlags

_________________
My first game : Twin Dragons available at Broke Studio.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 21 posts ]  Go to page 1, 2  Next

All times are UTC - 7 hours


Who is online

Users browsing this forum: Google [Bot] and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group