Can someone explain arpeggios?

Discuss NSF files, FamiTracker, MML tools, or anything else related to NES music.

Moderator: Moderators

Post Reply
zkip
Posts: 67
Joined: Tue Nov 20, 2012 1:59 pm

Can someone explain arpeggios?

Post by zkip »

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.
tepples
Posts: 22705
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: Can someone explain arpeggios?

Post by tepples »

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: Select all

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: Select all

    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.
User avatar
dougeff
Posts: 3078
Joined: Fri May 08, 2015 7:17 pm

Re: Can someone explain arpeggios?

Post by dougeff »

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
User avatar
rainwarrior
Posts: 8731
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: Can someone explain arpeggios?

Post by rainwarrior »

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.
zkip
Posts: 67
Joined: Tue Nov 20, 2012 1:59 pm

Re: Can someone explain arpeggios?

Post by zkip »

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.
User avatar
Memblers
Site Admin
Posts: 4044
Joined: Mon Sep 20, 2004 6:04 am
Location: Indianapolis
Contact:

Re: Can someone explain arpeggios?

Post by Memblers »

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..
Post Reply