Possible to play music that doesn't loop in Famitone2 (neslib)

Discuss technical or other issues relating to programming the Nintendo Entertainment System, Famicom, or compatible systems.

Moderator: Moderators

Post Reply
User avatar
Goose2k
Posts: 102
Joined: Wed Dec 11, 2019 9:38 pm
Contact:

Possible to play music that doesn't loop in Famitone2 (neslib)

Post by Goose2k » Thu Jun 04, 2020 9:46 pm

I am using famitone2 via neslib in C. I end my music with CXX to stop the music: http://famitracker.com/wiki/index.php?title=Cxx

This works fine in famitracker, and works fine for sound effects in my game. However, music always seems to loop no matter what.

I have also tried BXX to force an infinite loop at the end of the song, but that seems to be totally ignored as well.

Does anyone have any experience with this, or can confirm that usually this does in fact work in famitone2?

Thanks!
Attachments
Annotation 2020-06-04 214600.png
Annotation 2020-06-04 214600.png (7.73 KiB) Viewed 1198 times

User avatar
aa-dav
Posts: 92
Joined: Tue Apr 14, 2020 9:45 pm
Location: Russia

Re: Possible to play music that doesn't loop in Famitone2 (neslib)

Post by aa-dav » Thu Jun 04, 2020 11:27 pm

Famitone2 manual states:
- Allowed notes are C-1..D-6, Note Cut (rest note)
- Only Volume, Arpeggio, and Pitch sequences (no Pitch for noise
channel) supported
- All instruments should have a volume envelope assigned
- Only the loop part of sequence is supported, release part is not supported
- Pitch envelope accumulate the offset at conversion time only, thus
it can't go further -64..63, and can't accumulate the offset with loop
- Only first step of Duty envelope for pulse and noise channels is used,
there is no Duty sequence
- 64 instruments max
- No volume column support
- Tempo is set with the global setting, speed can be changed with effect
Fxx (1..21)
- Bxx effect for looping without an intro, does not support forward
references
- D00 effect to cut patterns early
- No effects other than listed above are supported
- Up to 17 sub songs in a file, they will share instruments and pattern
data

scrimpeh
Posts: 9
Joined: Tue Aug 02, 2011 3:11 am

Re: Possible to play music that doesn't loop in Famitone2 (neslib)

Post by scrimpeh » Fri Jun 05, 2020 3:00 am

As far as I'm aware, there is no way to get Famitone to stop music directly. I've been able to work around this by modifying Famitone's FT conversion program to set the song speed to 0 when it encounters C00. I haven't tested how robust it is for longer songs, but it works well for fanfares and the like.

If that is not feasible for you, you can build some logic around Famitone that stops the song after a certain amount of time has passed. It requires some external bookkeeping, but it works.

/ Edit:
I just tried the infinite loop method you described in the OP. That seems to work fine for me (and is infinitely simpler than my solution). Just make sure you insert note cuts appropriately.

User avatar
aa-dav
Posts: 92
Joined: Tue Apr 14, 2020 9:45 pm
Location: Russia

Re: Possible to play music that doesn't loop in Famitone2 (neslib)

Post by aa-dav » Fri Jun 05, 2020 4:12 am

Looking at famitone2 code I see another possibly interesting thing. This driver keeps pause state in bit 7 of FT_SONG_SPEED variable. Also if FT_SONG_SPEED is 0 oscillators for music are not updated at all (but sounds keep working).
Effect Fxx updates of FT_SONG_SPEED variable, so if we could pass 0 or >127 to it we will stop music from updating/playing. But as far as I understand there must be some command like note in command buffer after effects commands. I never do music by myself, so maybe it's obvious fact for versed people.

User avatar
dougeff
Posts: 2712
Joined: Fri May 08, 2015 7:17 pm
Location: DIGDUG
Contact:

Re: Possible to play music that doesn't loop in Famitone2 (neslib)

Post by dougeff » Fri Jun 05, 2020 8:43 am

I just have a frame with note cuts, and then a loop back to itself, on the next line.
nesdoug.com -- blog/tutorial on programming for the NES

User avatar
Goose2k
Posts: 102
Joined: Wed Dec 11, 2019 9:38 pm
Contact:

Re: Possible to play music that doesn't loop in Famitone2 (neslib)

Post by Goose2k » Fri Jun 05, 2020 10:01 am

Thanks for all the insight! This is what was originally in the song, and does not work for some reason. Is that what you are doing as well? Or am I missing something?

Is anyone willing to post an example famitracker song that I could test in my game (which works fine for them)? Maybe its something specific to the way I have coded things.
Attachments
Annotation 2020-06-05 095838.png
Annotation 2020-06-05 095838.png (8.08 KiB) Viewed 1097 times

scrimpeh
Posts: 9
Joined: Tue Aug 02, 2011 3:11 am

Re: Possible to play music that doesn't loop in Famitone2 (neslib)

Post by scrimpeh » Fri Jun 05, 2020 10:37 am

Goose2k wrote:
Fri Jun 05, 2020 10:01 am
Thanks for all the insight! This is what was originally in the song, and does not work for some reason. Is that what you are doing as well? Or am I missing something?

Is anyone willing to post an example famitracker song that I could test in my game (which works fine for them)? Maybe its something specific to the way I have coded things.
Remove the lower D00 from the pattern. It seems like it overrides the B02 in Famitone's conversion utility.

Post Reply