Can someone explain arpeggios?

This is an archive of a topic from NESdev BBS, taken in mid-October 2019 before a server upgrade.
View original topic
Can someone explain arpeggios?
by on (#188279)
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.
Re: Can someone explain arpeggios?
by on (#188290)
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.
Re: Can someone explain arpeggios?
by on (#188293)
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.
Re: Can someone explain arpeggios?
by on (#188297)
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.
Re: Can someone explain arpeggios?
by on (#188350)
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.
Re: Can someone explain arpeggios?
by on (#188410)
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..