How are pitch bends notated?

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

Moderator: Moderators

User avatar
rainwarrior
Posts: 8732
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: How are pitch bends notated?

Post by rainwarrior »

Some MOD formats implement linear pitch (logarithmic frequencies) as discrete steps, I think commonly 64 per semitone? You could implement something similar with a table of 12 note frequencies * 20 divisions of the semitone, and apply octaves through bit-shift operations. This would make linear pitch slides very simple, though granular, but I wouldn't expect the granularity to be a significant problem.

If you're talking about tool/UI notation as well, most musical editors I've seen generally treat a pitch slide as an effect applied to a note that otherwise appears "flat". MIDI piano roll editors will often just show a note as a straight horizontal bar, and a pitch bend would be an effect applied to the channel (visible on a separate control track below the note field, sometimes). With MOD trackers similarly you just play a note and then apply pitch changes in the effect column. I mentioned with lilypond how you just write \glissando between two notes for that, etc, which seems fine for text-based input.

PXTone does a piano roll, but I think it actually notates pitch bends with a bent note bar to show where it ends, which is pretty cool. (I don't have it installed or I'd take a picture.)
zzo38
Posts: 1096
Joined: Mon Feb 07, 2011 12:46 pm

Re: How are pitch bends notated?

Post by zzo38 »

With formats such as MOD/IT/XM/S3M, there are two common kind of portamento which can be "Amiga portamento" (meaning working with period values) or "linear portamento" (meaning working with a logarithmic scale). There are then commands which apply portamento up or down by a specified speed. AmigaMML (which compiles into MOD/XM) supports two methods of specifying portamento, which are command envelopes (which are almost direct MOD/XM commands), and auto-portamento (only for XM with linear slides) which are indicated with a slash between notes (but I don't know if any other program does something similar to the way AmigaMML does it).
(Free Hero Mesh - FOSS puzzle game engine)
User avatar
Bregalad
Posts: 8056
Joined: Fri Nov 12, 2004 2:49 pm
Location: Divonne-les-bains, France

Re: How are pitch bends notated?

Post by Bregalad »

That's what I'd do on an SPC700, which can multiply Y by A. But multiplication is quite a bit slower on a 6502.
Who cares ? Multiplication is still possible on a 6502. If, after having designed the sound engine, it really turns out to be too slow, you can always optimize it using tables later. You can also do the (a+b)^2 - a^2 - b^2 trick, which makes some types of multiplication very fast on the 6502.

Also for the pitch table granularity trick, I think 21 pitches values per semitones could be a useful values as it prevents the octave table to be more than 255 entries. It is not as intuitive as using a power of 2 though.
tepples
Posts: 22708
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: How are pitch bends notated?

Post by tepples »

Bregalad wrote:
That's what I'd do on an SPC700, which can multiply Y by A. But multiplication is quite a bit slower on a 6502.
Who cares ?
Developers of games that aren't turn-based care.
Multiplication is still possible on a 6502.
So is floating-point math; see Applesoft BASIC. But not everything that's possible is wise, especially in an application with a real-time constraint.
If, after having designed the sound engine, it really turns out to be too slow
I have done the math, and two 8-bit-by-8-bit multiplications without tables for each of the three pitched channels (pulse 1, pulse 2, and triangle) would add over 10 scanlines' worth of cycles to the cycle budget. In an engine targeted at NSFs and stand-alone music ROMs, such as FamiTracker's own engine, I could get away with fairly complex arithmetic. But Pently is targeted at real-time games. If I were to make a rule "portamento is permitted in menus and in turn-based games, just not in-game during real-time games", that would just turn into "Could you make portamento faster? The game for which I requested the feature is real-time."
you can always optimize it using tables later. You can also do the (a+b)^2 - a^2 - b^2 trick, which makes some types of multiplication very fast on the 6502.
When a music engine is on the order of 1.5K, and you're trying to squeeze it into your NROM or CNROM project or into the fixed bank of your UNROM, MMC1, or MMC3 project (so that you can put the songs and patterns into the switchable bank), a 1K quarter square table would nearly double it just for one effect. There's a set of flags for turning off each of several ROM-intensive effects at build time.

Nor do I want to have to maintain three or more different portamento implementations in the long term, one for each point on the time-space tradeoff curve:
  1. Amiga-style period-space portamento, which is likely to sound significantly different if you transpose the music, play on NTSC vs. PAL, or reuse a piece of music on a different platform to which I plan to port Pently in the future, and is likely to break even more if you try to combine it with vibrato or arpeggio
  2. Space-intensive portamento
  3. Time-intensive portamento
lidnariq
Posts: 11432
Joined: Sun Apr 13, 2008 11:12 am

Re: How are pitch bends notated?

Post by lidnariq »

What about linear slides (of period, I guess) from semitone to semitone, but re-indexing to the master tuning table as it crosses a threshold? (maybe one or two semitones, depending)
tepples
Posts: 22708
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: How are pitch bends notated?

Post by tepples »

That could work.

I guess my real concern is how to express how fast the slide is.
tepples
Posts: 22708
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: How are pitch bends notated?

Post by tepples »

In particular, the problem is the extreme dynamic range expected of a portamento effect. Some compositions using portamento want a rate of multiple semitones per frame, while others might be as slow as one semitone per second.

Pitch bend in MIDI sends the equivalent of one update per frame. Ex yy zz sets the pitch bend for channel x+1 to z*128+y, where that value ranges from 0 (minimum) through 8192 (centered) to 16383 (maximum). The range from minimum to maximum is implementation-defined, but PC-based MIDI implementations appear to default to a range of four semitones (center plus or minus two), and some synths allow changing the range using "registered parameter" control messages. But this representation is probably too data-dense for NES use, much like the rest of the MIDI and Standard MIDI File formats.

Trackers offer three models for pitch bend, all of which add or subtract a particular amount per frame as long as the effect is in operation. All support the period model; XM and IT also support a logarithmic model with 16 units per semitone.
  1. Open-loop portamento
    1xx (MOD, XM, FTM), Fxx (S3M, IT): Slide up. Add x units per frame to period.
    2xx (MOD, XM, FTM), Exx (S3M, IT): Slide down. Subtract x units per frame from period.
    E1x (XM), EFx (S3M, IT): One-shot slide up. Add x units per row to period.
    E2x (XM), FFx (S3M, IT): One-shot slide down. Subtract x units per row from period.
  2. Portamento to target
    3xx (MOD, XM, FTM), Gxx (S3M, IT): Change period by x units per frame toward the current note.
    5xy (MOD, XM), Lxy (S3M, IT): Continue previous portamento to target while adding x - y units to channel volume per frame.
  3. Portamento by interval
    Qxy (FTM): Add y semitones to current note, then do 3zz where z = 2*x+1.
    Rxy (FTM): Subtract y semitones from current note, then do 3zz where z = 2*x+1.
I had planned to support only the portamento to target model, with the portamento by interval simulated by using a grace note followed by the target note, and the open-loop model as portamento by an arbitrary large interval.

XM also supports "glissando", which quantizes slides to semitones, controlled by effects E30 and E31.
Post Reply