It is currently Sat Oct 21, 2017 9:59 pm

All times are UTC - 7 hours





Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: Attack channel
PostPosted: Sun Oct 11, 2015 7:08 pm 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 19115
Location: NE Indiana, USA (NTSC)
Instruments in my music engine are a hybrid of the NerdTracker II approach (a decay rate, a constant duty, and a 4-entry arpeggio envelope table) and the FamiTracker approach (frame-by-frame control of duty, volume, and arpeggio or fine pitch). An envelope consists of an attack envelope followed by a linear decay/sustain segment. The attack envelope takes 2 bytes per frame to describe the duty, volume, and relative pitch of each frame of the attack, analogous to the duty, volume, and arpeggio envelopes of FamiTracker. The decay/sustain has a single duty and volume level, plus a decrease rate measured in volume units per 16 frames.

One idea I had was to store a separate pitch for the attack and decay/sustain segments. This let me add a virtual track that sends attacks to the pulse 1, pulse 2, or triangle channel. It lets me run two sequences on one channel. Think of it as triangle drums without the drums.


Attachments:
attackchannel.nsf [1.77 KiB]
Downloaded 94 times
attackchannel.ogg [217.48 KiB]
Downloaded 92 times
Top
 Profile  
 
 Post subject: Re: Attack channel
PostPosted: Sun Oct 11, 2015 7:25 pm 
Offline
User avatar

Joined: Fri May 08, 2015 7:17 pm
Posts: 1784
Location: DIGDUG
Good. I like this approach. One bit for attack, one for sustain, one for decay. I don't feel you need a separate pitch for the attack phase (it's so short). Just one pitch and one pitch effect for the whole note should suffice.

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


Top
 Profile  
 
 Post subject: Re: Attack channel
PostPosted: Mon Oct 12, 2015 1:12 am 
Offline
User avatar

Joined: Fri Nov 12, 2004 2:49 pm
Posts: 7233
Location: Chexbres, VD, Switzerland
Awesome, it sounds like there is 2 triangle channels going on simultaneously. I didn't understand your post but it does not matter, it sounds very good !


Top
 Profile  
 
 Post subject: Re: Attack channel
PostPosted: Mon Oct 12, 2015 7:08 am 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 19115
Location: NE Indiana, USA (NTSC)
Thanks.

Did you fail to understand the concept of attack and sustain portions, or did you fail to understand the concept of overwriting? It matters little; I'll explain both.

Attack and sustain portions
This section assumes familiarity with FamiTracker envelopes and with volume fade effects in trackers. Consider the following volume envelope:
Code:
     ___
   _|   |___
  |         |___
  |             |_______
 _|             .       |_______________
|               .                       |_______________
|               .                               .       |____________
|               .                               .
| . . . . . . . . . . . . . . . . . . . . . . . .
 4 7 8 8 7 7 6 6 5                               3
 Attack phase    Sustain phase

You set an attack envelope 4 7 8 8 7 7 6 6. Then you set a sustain envelope starting at 5 with a decrease rate of 2, which produces a slope of -2 units per 16 frames, or -1/8 amplitude unit per frame.

Envelopes in my music engine are slightly more complex than this to allow for pitch and duty control, but this simplified model should help you begin to understand.

Attack injection
Normally the music engine has have five tracks going, each with its own position in a musical phrase:
  1. A standard melodic track that plays on pulse 1
  2. A standard melodic track that plays on pulse 2
  3. A standard melodic track that plays on triangle
  4. A track that triggers sound effects, used to create drums
  5. A track that can replace the attack on pulse 1, pulse 2, or triangle with a different note

Tracks 1, 2, and 3 are directly mapped to a hardware APU channel. Playing a note on one of these loads the variables for that channel's attack and sustain phases. If the remaining attack length is nonzero, it plays the attack one frame at a time; otherwise, it runs the sustain.

Track 4 is mapped to a drum kit. Each entry in a 25-entry array consists of two sound effect numbers. Usually one sound effect is on the noise channel and the other on the triangle channel if needed. Triggering a sound effect of the form "triangle portion of kick drum" allows triangle drums to interrupt the bass line.

Track 5 doesn't have its own hardware APU channel. Instead, it has a pointer to another channel (pulse 1, pulse 2, or triangle). When a note is played on track 5, the track overwrites that other channel's attack with the attack portion of the instrument chosen for track 5. This pauses the other channel's sustain until the attack finishes.

What you're hearing in this NSF is a bass line on track 3 and an instrument with a one-frame pop attack on track 5. Track 5 is set to write attacks on top of track 3, which causes its sustain to pause until the attack is finished. Because the attack has a different pitch, tracks 3 and 5 are effectively time-sharing the triangle channel. It's the melodic counterpart to triangle drums.


Top
 Profile  
 
 Post subject: Re: Attack channel
PostPosted: Mon Oct 12, 2015 8:48 am 
Offline

Joined: Wed Nov 10, 2004 10:17 pm
Posts: 142
I've wanted this kind of thing in Famitracker for awhile, virtual "channels" that interrupt the existing ones. Doing this manually can be a chore.


Top
 Profile  
 
 Post subject: Re: Attack channel
PostPosted: Mon Oct 12, 2015 9:15 am 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 19115
Location: NE Indiana, USA (NTSC)
Thank you for your interest, RushJet1. Perhaps you or someone else could help me think through other caveats about how a track affects an attack injected on top of its channel.

  • An instrument can specify "staccato", where each note is cut half a row before the note ends. Should this cut an injected attack?
  • Should regular note offs cut an injected attack?
  • Should a new note on an instrument with an attack of nonzero length cut an injected attack?
  • An instrument can specify "legato", where a new note does not restart the envelope but only changes the current note's pitch. This is used for hammer-ons and pull-offs and wind instrument grace notes. Should legato change the pitch of an injected attack?
  • If one or both tracks has arpeggio turned on, is the attack affected?

There are a few things I could add to mitigate these, with different effects on the player's RAM footprint:
  1. Have legato and note cut affect the attack phase only if attack and sustain pitches match, on the assumption that a match was not an injection.
    RAM: +0; composer must take care to avoid unisons
  2. Store a separate variable for whether an attack is injected.
    RAM: +3 BSS, or +0 if attack pitch bit 7 can be repurposed for this
  3. Don't inject attacks at all, but instead give the attack track its own virtual channel (with base pitch, attack state, and arpeggio state) that the pulse 1, pulse 2, and triangle channels consult, similarly to how sound effects work
    RAM: +2 ZP (-3 BSS for channel attack pitch; +2 ZP +1 BSS for attack track's attack state; +2 BSS for attack track's arpeggio state)


Top
 Profile  
 
 Post subject: Re: Attack channel
PostPosted: Tue Oct 13, 2015 7:39 pm 
Offline
User avatar

Joined: Thu Mar 26, 2015 6:34 pm
Posts: 32
This is super cool. I did something similar with the triangle when I covered a C-jeff tune (entirely using arpeggio macros), except I had bass, drums, a little melody at the same time.


Attachments:
File comment: pardon the name
Fuckthe2A03.nsf [9.59 KiB]
Downloaded 66 times
Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC - 7 hours


Who is online

Users browsing this forum: No registered users and 4 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