2A03 experiment: creating sawtooth waves from the triangle channel - FamiTracker

# FamiTracker

FamiTracker Support Forums

Skip to content

## 2A03 experiment: creating sawtooth waves from the triangle channel

Post your original music here and receive feedback.
Forum rules
This area is dedicated for original music, please do not post covers here.
Post Reply

- Print view

3 posts • Page 1 of 1

Lum
  Posts: 75
  Joined: Tue May 26, 2015 2:32 am

### 2A03 experiment: creating sawtooth waves from the triangle channel

- Quote

Post by Lum » Wed Nov 30, 2016 6:39 pm

Hey all!
Recently I was mulling over ways I could possibly produce a true sawtooth wave on the NES without expansion chips. It can't really be done with DPCM samples, you'll get something that more closely resembles a triangle wave. I've seen demos that successfully pull it off by rapidly writing to the DPCM's delta counter as if it were a raw PCM sample, and while that works, it's computationally expensive and can't be done in FamiTracker (and certainly not during an actual game).
So I thought, could this be done with the triangle wave? After all, if you were able to cut the triangle's wave pattern in half you'd end up with a sawtooth. So I tried it out, and it turns out you kind of can, albeit in a limited and slightly out-of-tune way. I'm sure there's a lot of room for improvement here, but take a look:

tri_saw_test.ftm
  (8.5 KiB) Downloaded 582 times

The main issue was figuring out how to reset the triangle's output level to create a "pop". It's harder than it sounds - the output level doesn't simply reset when you silence the triangle as one would expect. However, it turns out by playing either the highest or second-highest possible frequency, you can get the triangle to instantly switch to an output level of 7.5. Bingo. While FamiTracker doesn't technically allow notes that high, using a value of -127 in a hi-pitch macro will accomplish that task.
The other issue is that to do this in FamiTracker you have to crank the engine speed way up - in this case I turned it up to 1000 Hz. However, I would assume that if something like this were implemented in an actual game, the engine speed could be left at 60 Hz and only the triangle's hi-pitch macro would need to run at such a high speed. By my calculations it could probably be done with a scanline counter triggering an interrupt every ~16 scanlines or so (that wouldn't result in exactly 1000 Hz like that FTM there, so the pitch would be different, but it'd be in that ballpark.) I think that would still leave enough processing time for an actual game to take place.
So, what do you guys think about this? Could a trick like this be useful for 2A03 composition/homebrews/demos?
Top

Tobikomi
  Posts: 511
  Joined: Wed Jun 10, 2015 8:17 pm
  Location: Wisconsin, USA

### Re: 2A03 experiment: creating sawtooth waves from the triangle channel

- Quote

Post by Tobikomi » Wed Nov 30, 2016 9:53 pm

This is fucking genius! Kudos to you!
ぼくのなまえはブライアン（とびこみ）だ。はじめまして！
My name is Bryan (Tobikomi). Nice to meet you!
My Soundcloud: https://soundcloud.com/bryan-ness-699934457/tracks
My Chipmusic: http://chipmusic.org/gameputer_bryan3
Top

Rarest_lizard038
  Posts: 62
  Joined: Wed Jul 01, 2015 2:20 pm

### Re: 2A03 experiment: creating sawtooth waves from the triangle channel

- Quote

Post by Rarest_lizard038 » Wed Nov 30, 2016 10:04 pm

Oh jeez. The metagame is evolving. This seems so unreal!
This trick could easily any song sound like its being played on the vrc6!
Top

Display posts from previous:
Sort by

Post Reply

- Print view

3 posts • Page 1 of 1

Return to “Original Music”

Jump to

- Rules
- Wiki
- FamiTracker
- General Talk
- Bug Reports
- Feature Requests
- Source and development
- Music
- Original Music
- Cover Music
- Other
- Site Issues & Suggestions