Music Playback Very Slow

Discuss NSF files, FamiTracker, MML tools, or anything else related to NES music.

Moderator: Moderators

User avatar
Goose2k
Posts: 320
Joined: Wed May 13, 2020 8:31 am
Contact:

Music Playback Very Slow

Post by Goose2k »

Hi,

I'm pretty new to NES development, and even more so NES Music.

I am making an NES game in C using neslib, with music playback via famitone2.

The musician I am working with has sent me a music track which, when played in famitracker or exported as an nsf, sounds totally fine. However, when I export it for playback in game, it plays very very slow (like 25% slower maybe).

I suspect it might have something to do with all the tempo fx being applied (1 every beat), because when I remove all of them the song plays back fine (although now the tempo is right, but it sounds the same as famitracker).

However, if I apply the same tempo fx so another same song I have, it works fine in that case, so there must be something additional to this file that I am not catching.

Any suggestions on how to debug this further?

Note: The tempo fx are on the otherwise unused DPCM channel, but I originally suspected that channel might be the problem and transfered all the fx to the Pulse 1 channel, but the issue happens there too.

I've attached both the famitracker file, and rom.

(Aso: Is this the right forum for this kind of question, or should it go in the nes dev forum? )
Attachments
main.nes
(40.02 KiB) Downloaded 217 times
WhatsKraken_Title_noDPCM.ftm
(50.21 KiB) Downloaded 208 times
User avatar
Gilbert
Posts: 564
Joined: Sun Dec 12, 2010 10:27 pm
Location: Hong Kong
Contact:

Re: Music Playback Very Slow

Post by Gilbert »

Haven't checked the ROM, but maybe somehow your game is run in 50Hz PAL mode (like because of header settings) so the music are slower?

Edit:
Hmmm Nestopia reported that it's NTSC. Don't know about it then.
Last edited by Gilbert on Mon Jun 01, 2020 10:17 pm, edited 1 time in total.
lidnariq
Posts: 11429
Joined: Sun Apr 13, 2008 11:12 am

Re: Music Playback Very Slow

Post by lidnariq »

Without debugging symbols, this is a bit harder, but it tentatively seems like the playback engine is never successfully changing the "speed" from the default of 6, instead of the very fast (1 or 2) that the FTM indicates.
User avatar
Goose2k
Posts: 320
Joined: Wed May 13, 2020 8:31 am
Contact:

Re: Music Playback Very Slow

Post by Goose2k »

One thing to keep in mind is that other music plays back fine in the exact same game (just swapping out the exported music .s file). So I think it is something unique about this particular song (although possibly just exposing a bug in my code the other song did not).

But the c code for playing music is 1 line. :D

I've attached the whole game if you feel like looking any deeper.

The source is on git hub too: https://github.com/mhughson/mbh-firstnes/
Attachments
game.zip
(152.83 KiB) Downloaded 210 times
User avatar
Goose2k
Posts: 320
Joined: Wed May 13, 2020 8:31 am
Contact:

Re: Music Playback Very Slow

Post by Goose2k »

After reducing this song down to just 1 frame of music, I think I have narrowed down the issue.

The issue appears to occur whenever there is a note played on all 4 channels, and at the same time a tempo fx is applied.

music_broken_line.png

I suspect this is a bug in famitone2, since this plays fine in NSF format. Does anyone know if anyone maintains the library anymore? Perhaps there is already a fix out there?

music_works_no_overlap.png
User avatar
Goose2k
Posts: 320
Joined: Wed May 13, 2020 8:31 am
Contact:

Re: Music Playback Very Slow

Post by Goose2k »

Just in case anyone stumbles on this hoping to find a solution, the solution I posted above did not actually fix the issue. I mean it did for a very small example song, but when I applied the solution to a full song, it still played back very slow.

To fix it, the musician just redid the song without FXX. :oops:
User avatar
tokumaru
Posts: 12427
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Re: Music Playback Very Slow

Post by tokumaru »

I just stumbled on the same problem. In my case it's happening when I have Fxx effects in seemingly random rows, I don't see any correlation between them. Even rows without any notes or anything will trigger the problem when I put Fxx effects on them, and I just can't figure out what these specific rows have in common. If I skip them, the remaining speed changes work normally, otherwise all speed changes are stripped out by text2data.exe and the song plays at the speed of 6, very slowly. I can only assume this is a bug in text2data, since a lot of data goes missing from the file it exports once you add a single Fxx effect to a problematic row.
User avatar
dougeff
Posts: 3078
Joined: Fri May 08, 2015 7:17 pm

Re: Music Playback Very Slow

Post by dougeff »

I tested Matt's file and I'm not getting an error, as far as I can tell. The data is correct.

I have heard that Famitone doesn't handle speed of 1 very well, F01.
nesdoug.com -- blog/tutorial on programming for the NES
User avatar
tokumaru
Posts: 12427
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Re: Music Playback Very Slow

Post by tokumaru »

dougeff wrote: Tue Feb 23, 2021 9:33 pmI have heard that Famitone doesn't handle speed of 1 very well, F01.
It doesn't matter if I use F01 or F02, alternating either of them with F04 every row makes the song play at the default speed of 6...
User avatar
dougeff
Posts: 3078
Joined: Fri May 08, 2015 7:17 pm

Re: Music Playback Very Slow

Post by dougeff »

Funny. I'm not getting the same error as you. I have tested it. The data is correct. The song speed goes 1,2,1,2 for Matt's song, and 4,1,4,1 for Tokumaru's song, as expected.

(shrug) it sounds right to me.

Matt's song
$fb,$02, speed 2
$81, 1 row
$fb,$01, speed 1
$81, 1 row
$fb,$02, speed 2
$81, 1 row
$fb,$01, speed 1
$81, 1 row
$fb,$02 speed 2
etc

Tokumaru's song
$fb,$04, speed 4
$81, 1 row
$fb,$01, speed 1
$81, 1 row
$fb,$04, speed 4
$81, 1 row
$fb,$01, speed 1
$81, 1 row
$fb,$04 speed 4
etc
Last edited by dougeff on Tue Feb 23, 2021 10:49 pm, edited 1 time in total.
nesdoug.com -- blog/tutorial on programming for the NES
User avatar
tokumaru
Posts: 12427
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Re: Music Playback Very Slow

Post by tokumaru »

Are you using the original Famitone2 and conversion tool? When played back in an actual ROM it's definitely not using the Fxx data at all.
User avatar
dougeff
Posts: 3078
Joined: Fri May 08, 2015 7:17 pm

Re: Music Playback Very Slow

Post by dougeff »

I used famitone 2, text2data, 4'17 build

do you have?
FT_DPCM_ENABLE = 1

because those speed effects are on the DPCM channel.
nesdoug.com -- blog/tutorial on programming for the NES
User avatar
tokumaru
Posts: 12427
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Re: Music Playback Very Slow

Post by tokumaru »

dougeff wrote: Tue Feb 23, 2021 10:51 pmdo you have?
FT_DPCM_ENABLE = 1

because those speed effects are on the DPCM channel.
No, but the effects in that column are processed anyway as long as I don't put them in every row.
User avatar
dougeff
Posts: 3078
Joined: Fri May 08, 2015 7:17 pm

Re: Music Playback Very Slow

Post by dougeff »

I'm pretty sure it needs to be enabled or it won't read the stream from that channel.

perhaps the encoder, text2data, is moving the effects to channel 0 data stream... some times, but not all the time.

And the times that it DIDN'T move it, it failed because you didn't enable DPCM. (I'm guessing?)
nesdoug.com -- blog/tutorial on programming for the NES
User avatar
tokumaru
Posts: 12427
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Re: Music Playback Very Slow

Post by tokumaru »

dougeff wrote: Wed Feb 24, 2021 5:38 amperhaps the encoder, text2data, is moving the effects to channel 0 data stream... some times, but not all the time.

And the times that it DIDN'T move it, it failed because you didn't enable DPCM. (I'm guessing?)
That does make sense... I'll give it a try.

Still, if this is the case, I wonder why it doesn't move the effects in certain cases, and what was the problem in the op's case, since he didn't have the effects in the DPCM channel.
Post Reply