It is currently Sun Dec 17, 2017 2:49 pm

All times are UTC - 7 hours





Post new topic Reply to topic  [ 6 posts ] 
Author Message
PostPosted: Thu Feb 02, 2017 11:16 am 
Offline

Joined: Tue Nov 20, 2012 1:59 pm
Posts: 65
Now that the contest is over, I've found out that I really like coding for these old school consoles. However, a full game is a bit taxing. Long story short I'd like to get into coding demos and the likes. Some might hate them, but arpeggios play an important role in vgm history. I'm rambling on here so I'll get to the point, I'd like someone to explain from a programming stand point how to implement arpeggios into a NES music engine. I know they are usually a loop? of the base notes 3rd, and fifth. But I'm not sure how to implement that. Like do they slide or is it just three notes played at fast intervals. If so I'd also appreciate someone explaining these intervals.

Thanks, zkip.


Top
 Profile  
 
PostPosted: Thu Feb 02, 2017 1:01 pm 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 19354
Location: NE Indiana, USA (NTSC)
Assuming that by "arpeggio", you're referring to arpeggio effects in the pattern, not arpeggio-type envelopes on instruments.

Let's say the pattern enables the arpeggio effect 047. This means arpeggio1 = 4 and arpeggio2 = 7. The numbers represent intervals measured in semitones: 4 is a major third above the base note, and 7 is a perfect fifth above the base note. Thus 047 represents a major chord in inversion 0.

Here is pseudocode:
Code:
On note start:
    Set arpeggio phase to 0
    Remember the base pitch of the note
Each frame:
    If arpeggio phase == 0:
        Set pitch to base pitch
    If arpeggio phase == 1:
        Set pitch to base pitch + arpeggio1
    If arpeggio phase == 2:
        Set pitch to base pitch + arpeggio2
    Add 1 to arpeggio phase
    If arpeggio phase >= 3:
        Set arpeggio phase to 0

Let me know the first line you don't understand.

This allows for no arpeggio (arpeggio1=0 and arpeggio2=0), even combinations of three notes (arpeggio1=x and arpeggio2=y), a combination of two notes with more of the base note (arpeggio1=0 and arpeggio2=x), a combination of two notes with more of the upper note (arpeggio1=x and arpeggio2=x)

One enhancement is to replace the last if-then as follows:
Code:
    If arpeggio phase >= 3:
        Set arpeggio phase to 0
        If arpeggio2 == 0:
            Set arpeggio phase to 1

This allows an additional type of arpeggio: an even combination of two notes (arpeggio1=x and arpeggio2=0).

The Pently music engine implements exactly this arpeggio algorithm. In pentlymusic.s, look around storePitchWithArpeggio.


Top
 Profile  
 
PostPosted: Thu Feb 02, 2017 1:21 pm 
Offline
User avatar

Joined: Fri May 08, 2015 7:17 pm
Posts: 1870
Location: DIGDUG
Famitracker....instrument...arpeggio...type | 0 4 7 (must have a pipe first), or | 0 4 7 4

Also, other intervals are interesting...
0 4 11 4
0 4 12 4
0 5 12 5
0 2 7 2
0 7 14 7
etc...

EDIT - 'pipe' is slang for a vertical bar.

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


Top
 Profile  
 
PostPosted: Thu Feb 02, 2017 1:31 pm 
Offline
User avatar

Joined: Sun Jan 22, 2012 12:03 pm
Posts: 5899
Location: Canada
I'd recommend using Famitracker and trying out the arpeggio instrument envelopes.

There's a lot more to it than just repeating 3 notes on successive frames. You could use 2 or 3 frames per note for a slower effect. You can use loops of other lengths, 2 notes or 7 notes or whatever sounds interesting/appropriate to you. It is often very effective combined with other types of envelopes (i.e. changes of volume or duty).

Maybe also consider things besides just major or minor triads, and arpeggios wider than a single octave (12 semitones). An arpeggio might sweep up and down in order of pitch, or the the order might jump up and down erratically. They don't even have to loop! There are all sorts of interesting effects to try.

There are some good examples here:
https://www.youtube.com/watch?v=4HWHneafZ8w

One way to study these things is to use this NSF Importer tool to inspect NSF files in Famitracker. It breaks down everything an NSF is doing frame by frame (each frame on a single row), showing you exactly what it's made of:
http://rainwarrior.ca/projects/nes/nsfimport.html


zkip wrote:
Like do they slide or is it just three notes played at fast intervals.

It's not a slide effect, the pitch is changed immediately on a per-frame basis.


Top
 Profile  
 
PostPosted: Fri Feb 03, 2017 8:41 am 
Offline

Joined: Tue Nov 20, 2012 1:59 pm
Posts: 65
Thanks guys. I understand perfectly now and it's implemented in my engine. It really is crazy all of the interesting combinations of sounds you can get with these, and I haven't even tried adding volume envelopes to them yet. My next mission is to play around with those Rob Hubbard style sawtooth DPCM tricks. Thanks again guys.


Top
 Profile  
 
PostPosted: Sat Feb 04, 2017 12:04 am 
Offline
Site Admin
User avatar

Joined: Mon Sep 20, 2004 6:04 am
Posts: 3488
Location: Indianapolis
If you're looking for something fancy to put in a sound engine, I'd recommend taking a look at something blargg came up with:
http://www.slack.net/~ant/misc/nes-saw/
Such a cool trick, it's practically a crime that no one has used this in a music engine (AFAIK), other than the demos on that page. DPCM sawtooth (or other waves), with volume control..


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC - 7 hours


Who is online

Users browsing this forum: Majestic-12 [Bot] and 3 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