Control pitch and speed of a sample in Famitone

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

Moderator: Moderators

Post Reply
User avatar
NOOPr
Posts: 64
Joined: Tue Feb 27, 2018 10:41 am
Location: Brazil
Contact:

Control pitch and speed of a sample in Famitone

Post by NOOPr » Thu May 23, 2019 6:24 am

Is it possible to change the famitone code in order to control the speed and/or pitch of a DPCM sample?
The idea is to pass the speed and/or pitch in registers X/Y as parameters of the subroutine FamiToneSamplePlay.
Thanks in advance.

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

Re: Control pitch and speed of a sample in Famitone

Post by dougeff » Thu May 23, 2019 8:09 am

DPCM doesn't have a pitch adjustment. It does have a sample rate adjustment (which affects pitch).

If you want specific pitches, you probably need a separate sample for each pitch.

Famitone usually loads from a table called "samples"

You could make the rate a variable. Instead of

FamiToneSamplePlay:
...

lda (FT_TEMP_PTR),y ;pitch and loop
sta APU_DMC_FREQ

have

lda variable
sta APU_DMC_FREQ
nesdoug.com -- blog/tutorial on programming for the NES

User avatar
NOOPr
Posts: 64
Joined: Tue Feb 27, 2018 10:41 am
Location: Brazil
Contact:

Re: Control pitch and speed of a sample in Famitone

Post by NOOPr » Thu May 23, 2019 2:58 pm

Works like a charm!

The value on the table 'samples' generated by text2data for frequency and loop is at high value for frequency ($0f) so I could only low the frequency...below $0d the audio becomes just noise...but works anyway.

Thank you so much for the help.

Post Reply