Mindboggingly simple way to control legato (ftm inside)

This is an archive of a topic from NESdev BBS, taken in mid-October 2019 before a server upgrade.
View original topic
Mindboggingly simple way to control legato (ftm inside)
by on (#200070)
Background:
In FamiTracker (and other engines), the default mode of notes is legatissimo (as legato as possible, that is, the notes are glued together as one). This is technically straightforward, but musically not always desired. Then, normally, we make an accent at the beginning of a volume envelope of an instrument to distinguish the notes by some. This would, in music theory, make them simply Legato, since they're still bound together. Then, by dropping the volume to 0, you can get both staccatissimo and staccato. But there's a middle ground that's left out the way FamiTracker works: Notes that indefinitely sustain themselves but still are distinct from the next.

I've done the following for long* with Bass notes:
Volume Envelope MML: [0 1] or [0 anything]. This put the notes one sample behind the other instruments, but it works well to make the sound distinguishable, plus, the tone of an electric finger bass comes a little behind too, if you examine a waveform closely. This is just omitting the atonal attack.

But what about if we want to easily shift between playing with or without with legato - without resorting to staccati or notes fading at a predetermined length)?

Then it struck me:

1) Treat EVERY instrument as the bass. Add 0 to the beginning of EVERY volume envelope of EVERY instrument. Since litteraly everything is delayed one sample, it isn't percieved as a delay at all. If you're using other envelopes than volume, you should add a dummy sample at the beginning to those aswell.

2) Then, for the instruments you want to control legato on, clone those instruments. Add a new volume envelope. Copy and Paste the mml string; remove the zero. Again, if you use more envelopes, you might want to clone those envelopes aswell, depending on how pedantic you are with the sound.

3) Switch instruments between non-legato and legato as you please.

Small caveat: Legato notes will be one sample ahead. If you find it stands out too much, see below.
Remedy: use the Gxx effect to delay it a frame. Legato will still hold.

Example file playing a winners' fanfare, with and without legato. First, nonlegato is played. Then, the default legato:
Attachment:
fanfare_nonlegato_legato.ftm [2.01 KiB]
Downloaded 162 times


Notes:
*Well, i've only used famitracker for half a year or something.
Re: Mindboggingly simple way to control legato (ftm inside)
by on (#200072)
Yep, that's a fairly common technique. Most of Super Mario Bros. instruments start with 1 frame of volume 0, for example.


By the way, did you know that Famitracker has a forum?
http://forums.famitracker.com/index.php

Not that the stuff you've been posting isn't relevant here, but there's a whole lot of people there that discuss these kinds of things more regularly than at this forum where relatively few people are interested in making music. You might pick up a lot of good ideas from people there. (Though I must confess I am no longer a regular poster there.)

Similar motivation led me to create the NSF Import tool for studying NSFs withing Famitracker.
Re: Mindboggingly simple way to control legato (ftm inside)
by on (#200085)
Hi. :)

Not that I am in any way discouraging you from sharing your FTM or 0CC files here... You may wish to be a part of the FamiTracker community and forums; also on the FamiTracker Discord server. People share and discuss their methods regularly in those areas.

Secondly, effectively FamiTracker has been superseded by 0CC-FamiTracker. 0CC files are not compatible with FamiTracker; as they have additional driver modifications that the community has supported.

NESdev community members DO use FamiTracker, but they would not necessarily be on the cutting-edge of tracker techniques or musical discussion of the platform. Another community I would suggest is Battleofthebits if you wish to be a part of a graphical art, coding, and musical production community based on competition and education. (Please use your favorite search engine to discover relevant references. ;))
Re: Mindboggingly simple way to control legato (ftm inside)
by on (#200110)
FrankenGraphics wrote:
1) Treat EVERY instrument as the bass. Add 0 to the beginning of EVERY volume envelope of EVERY instrument. Since litteraly everything is delayed one sample, it isn't percieved as a delay at all. If you're using other envelopes than volume, you should add a dummy sample at the beginning to those aswell.

2) Then, for the instruments you want to control legato on, clone those instruments. Add a new volume envelope. Copy and Paste the mml string; remove the zero. Again, if you use more envelopes, you might want to clone those envelopes aswell, depending on how pedantic you are with the sound.

3) Switch instruments between non-legato and legato as you please.

To be honnest this sounds more like a hack. A good sound engine (like the ones I code) do this by default - always start notes with a silent frame (and implicitely delaying everything one frame). Legato should be enablable and disableable explicitely without making different volume envelopes - also when legao is enabled the volume enveloppe should not restart (for example if there is an attack it should only be heard after silents but not if there is several consecutive notes). On systems where samples are supported, the samples should not restart but continue to loop/play and only change frequency.

This is basic sound engine stuff. Famitracker is obviously limited.
Re: Mindboggingly simple way to control legato (ftm inside)
by on (#200111)
I've always tried to address this from both directions: My engines can either have a length counter-like timer in software to stop the sound, or a "stop the sound when less than X frames of duration are left for this note". It makes things as opened up as I need them to be.
Re: Mindboggingly simple way to control legato (ftm inside)
by on (#200113)
I was hoping this would incite a discussion on engine design/programming. :) With the two applications you described, file size can be kept a bit smaller; especially if you use lots of instruments.

re: bregalad, on envelope trig/notrig: That very much depends on what (physical world) instrument you're playing (or mimicking). A piano will always have an accent*, regardless legato/legatissimo. As will classical/spanish guitar. Taps have (different) accents, slides are simply glissandi.

In analogue synth talk/practice, the mode you're describing is pretty standard, but it is likely due to a historic compromise where cost effectiveness has trumped user-oriented design. The method has since then become a culture in itself. I often find it cumbersome and mildly annoying when playing synths that got this particular legato setup hardwired. It's an arbitrary limitation and prone to false trigs/nontrigs. Another reason to abandon prepackaged synths and go modular: full interface control :roll: One thing that's almost always better is to have legati notes trig a different envelope (and derive the max of both), rather than none at all. Or for a piano-like interaction, just trig the same.

re: bregalad, regarding the rest: Despite FT not supporting nonlegato/legato directly/out of the box, it's rather flexible as far as 2A0x goes. It seems N163 is a bit arbitrarily limited for the sake of a non-technical user interface.

Another thing to consider: you may want your pauses wider than one sample: In that case, you could have:
[0 0 x ] = non legato, with very strong note separation
[ 0 x ] = non legato, but close
[x] = legato

add delay effects to compensate accordingly.

It can definitely be labelled a hack/trick, but a very functional one in any engine not featuring legato/nonlegato switching of some sort.

Re: rainwarrior, b00daw: Thanks for your suggestions! I'm a registrerad user at the FT forums but have remained an irregular lurker, mostly, besides posting a few ftm files, so i haven't really taken a swim there yet.

I suspected the trick was about as old as the NES itself, but it felt like a revelation when the penny dropped. :P I was hoping a quick tutorial might benefit homebrewers who're looking to roll their own bgm:s, if there's such a target audience. It looks like we're seeing more division of labour (dev + artist combos)?

To what extent is 0CC-FT suitable for NES development?

*not to be confused with note accents
Re: Mindboggingly simple way to control legato (ftm inside)
by on (#200115)
za909 wrote:
My engines can either have a length counter-like timer in software to stop the sound, or a "stop the sound when less than X frames of duration are left for this note". It makes things as opened up as I need them to be.

Pently has a "detached" bit on each instrument, which means cut it when half a row remains. Its concept of "legato" is to change the pitch of an existing note and ignore the detached bit.
Re: Mindboggingly simple way to control legato (ftm inside)
by on (#200121)
FrankenGraphics wrote:
To what extent is 0CC-FT suitable for NES development?

0CC is a fork of Famitracker with whatever extra features HertzDevil wanted to see.

I don't think any of those extra features are really relevant for use in an NES game. For the same reason that most game engines would want to use their own compact/subset music engine instead of the full Famitracker driver, the extra features of 0CC require more driver code to support. I think 0CC is mainly of interest to people just making music / NSFs and were frustrated by the (stagnant?) pace of regular Famitracker development-- though I think the existence of 0CC itself might have contributed to jsr losing interest in continuing Famitracker. :(

Bregalad wrote:
A good sound engine (like the ones I code) do this by default - always start notes with a silent frame (and implicitly delaying everything one frame).

This statement is a bit strange to me, at least in an NES context. For sampler based music engines, and also with FM, I have seen this primarily to be able to release a note smoothly and quickly before the next frame, rather than a hard cut, but that's not something that happens on the NES. Why should a "good" NES music engine delay everything by one frame? (Do you know of NES music engine examples that do this? SMB does not, it's doing it through envelopes like FrankenGraphics described, and the other channels without such an envelope start a frame "early".)

This "volume 0 as note start" idea can be useful for breaking up plain tones, but I'd never think of that as the default way to start a note on the NES. There's a million other ways to start a note with an envelope that will make the beginning of it sound distinct from the previous tone.


One similar trick that some people like to do in Famitracker is put an H00 effect, which is supposed to be a null hardware pitch slide but had the side effect in the engine of rewriting high pitch and resetting the phase of the square channel it's on. This adds a little "pop" discontinuity where the phase is reset, though if the previous phase is unlucky it might be quiet. A lot of NES engines actually start every new note with a full phase reset. I think the volume 0 envelope start is a much more robust solution to that problem, but this is an alternative that I've seen used in both commercial games and as H00 by Famitracker users.
Re: Mindboggingly simple way to control legato (ftm inside)
by on (#200134)
Just to show how varying between non-legatos with different pauses can be useful/dramatically change the sound:

Fanfares in order:
1. Legato [x]
2."Semilegato" [0 x] (previously called nonlegato. There's really no such thing as a semilegato*)
3. Nonlegato [0 0 x]

While the separation happens between 1 and 2, the 3rd has a stronger rythmic presence because the aural senses have more time to "land" on the difference while still having the prior samples fresh in mind. Too long a pause and this presence will disappear again.

Go ahead and change around in the instrument columns - you can often get away with mixing them, so you can use delays to taste when you think something felt too off beat just as well as you could aim to quantize it all. It can even be a feature refraining from quantizing the notes too much to make the bgm more "live played".

Attachment:
fanfare_legato_semilegato_nonlegato.ftm [2.79 KiB]
Downloaded 135 times


*My italian is limited to what the cookbook says, but
Semi = half
Legato = tied/glued together.

Half-tied together? Nah. To the ear, the notes are, or they aren't. #2 falls just outside what could be percieved as a legato.
Re: Mindboggingly simple way to control legato (ftm inside)
by on (#200135)
Unrelated to the legato thing you're trying to demonstrate, I might point out that your vibrato pitch envelopes are off centre, which becomes especially noticeable at higher pitched notes. The central pitch is lower than where it should be, and it's twice as detuned-low when it transitions from the "1" to "2" part of the loop.

Your pitch loop goes down from the starting pitch, then back up, then loops. A symmetrical loop should go 50% up, then 100% down, then 50% back up before looping.

off centre: | 1 1 -1 -1 (resulting pitch offset: 1 2 1 0 1 2 1 0...)

centred: | 1 -1 -1 1 (resulting pitch offset: 1 0 -1 0 1 0 -1 0...)
Re: Mindboggingly simple way to control legato (ftm inside)
by on (#200136)
Quote:
vibrato
Thanks! ugh, wouldn't be the first time i messed that up. :? Fixed it.
Attachment:
fanfare_legato_semilegato_nonlegato.ftm [2.79 KiB]
Downloaded 135 times
(For synthesizing flutes and some other woodwinds, you'd want the vibrato to "dip" asymmetrically, because that's how you play the flute/how the flute sounds - but generally not for many other instruments).
Re: Mindboggingly simple way to control legato (ftm inside)
by on (#200144)
Your new vibrato is strange. It spends 1 frame in 6 at a different pitch before reverting to the original? It sounds more like a periodic "blip" than a change in pitch.

new vibrato: | 3 -3 0 0 0 0 -3 3 0 0 0 0 (result: 3 0 0 0 0 0 -3 0 0 0 0 0...)

You could spread it out over the loop for a much smoother vibratio:

smoother alternative: | 1 1 1 -1 -1 -1 -1 -1 -1 1 1 1 (result: 1 2 3 2 1 0 -1 -2 -3 -2 -1 0...)

Or if you want a more "square" LFO:

square vibrato: | 3 0 0 0 0 -3 -3 0 0 0 0 3 (result: 3 3 3 3 3 0 -3 -3 -3 -3 -3 0...)


Also, pedantically because of the linear vs. logarithmic nature of pitch, even the balanced pitch envelope isn't quite "centred" but it's close enough for all musical purposes, really. The NES isn't a precision tuning instrument to begin with, so a true ideal balance is not really possible. (Though some have experimented with MOD style linear pitch for more intuitive/natural pitch slides, I think that is an 0CC feature, actually.)
Re: Mindboggingly simple way to control legato (ftm inside)
by on (#200156)
Thanks - that cured me of a foggy misconception on how the pitch envelope works.

I ended up with this for now:

0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 (delay)
1 0 0 0 0 -1 -1 0 0 0 0 1 (vibrato start)
1 1 0 0 -1 -1 -1 -1 0 0 1 1 (increase)
| 1 1 1 -1 -1 -1 -1 -1 -1 1 1 1 (vibrato max; loop)


A bit wasteful and a subtle difference compared to just turning vibrato on , but i think it's nice.
Re: Mindboggingly simple way to control legato (ftm inside)
by on (#200158)
If you're using it for a game, I think it's pretty sensible to drop almost all of the Famitracker effects and just do all vibrato via pitch envelopes. Each effect costs RAM and code complexity, and the instrument envelopes are really very versatile already.

If you're just making music for music's sake though, I'd use whatever seems to work best. There's good use cases for any Famitracker effect. You can do more complicated vibrato with envelopes than the vibrato effect (e.g. you've already hit on the gradually increasing vibrato idea), though it is tied up with instrument definitions.


Personally, all I kept for my engine was Bxx (loop point), Dxx (irregular pattern length), and Fxx (speed change), and also the volume column. I also discarded the hi-pitch envelope, which seemed unnecessary.

Other people's engines keep various things, with Famitone shiru didn't think volume control or duty envelopes were important. Tepples' Pently has a bunch of concepts that he felt were useful that don't map to Famitracker features. For Haunted Halloween I was asked to add a bunch of Famitracker effects to Famitone (in particular the portamento stuff, which became kind of a unique feature of its soundtrack), and there have been other efforts to add stuff to Famitone. There seem to be a lot of differening ideas about what's important in a music engine, and what's not.
Re: Mindboggingly simple way to control legato (ftm inside)
by on (#200173)
Famitracker works much better if you use Note Off commands (backslash key \ ). Then you define Release envelopes for the note to fade as it encounters the Note Off event. Release envelopes are sorta like the loop envelopes, but it's like this: x x x x | x x x x / x x x x. | is the loop, / is the release. For some reason, the first one from the release is also treated as part of the loop.

Alternatively, if you don't like dirty hacks, I think the proper command is S0X, where X is your speed in frames minus 1.
Re: Mindboggingly simple way to control legato (ftm inside)
by on (#200182)
Yeah, every piece i do is meant to be either directly applied or easily converted to work with some BGM engine or another. I find it hard to motivate myself if it wouldn't be applicable.

I don't think any of the common engine (famitone, pently) supports the fine-tune effect i'm using here, but it's easy to work around. Digression:
I do see *some *value in that effect as it allows me to detune/chorus independently from using an instrument vibrato (making multiple vibrati instruments just with varying detunes would be size ineffective), but since vibrati tends to kick in after a while, i could in this case get away with non-vibrating detuned instruments for the short notes + gain finer control over when the detune kicks in. But it for the sake of the example file, having just one instrument for each legato/nonlegato mode was clearer.


One thing i find very convenient/useful is being able to gliss x seminotes up/down over n time, but that can also be worked around, albeit uncomfortably/a bit backwards; sometime size ineffectively.

Hi-pitch would be useful if you want percussion and/or percussive attacks on tonal notes.

What common engines support the note off MML command? It could be used for a lot more than "just" simple releases
Re: Mindboggingly simple way to control legato (ftm inside)
by on (#200867)
Interesting post. It made me go in and try adding volume 0 to the beginning of some of my envelopes. I didn't like how it sounded in the context of my own music. I find that the style of attack in a volume envelope is often enough to give a punchier sound to the beginning of notes (which may or may not include a volume entry of 0 at the beginning) When I want it to sound like an instrumentalist is tonguing their clarinet or whatever I use note cuts. In other words, I don't think it necessarily makes sense to use this hammer for all nails, so to speak.

*edit* I suddenly realized however this may be incredibly useful for fast triangle tremolo picking, so that I don't have to have different length envelopes for NTSC and PAL for instance. (thinking of a case where note cuts don't 'cut it') I'll have to try this out. Thanks for the thoughts.
Re: Mindboggingly simple way to control legato (ftm inside)
by on (#200903)
Yeah, having the tri bass play 8th note/quaver or semiquaver (for example) makes the notes distinct without having to care for playback speed vs envelope length.
Re: Mindboggingly simple way to control legato (ftm inside)
by on (#203317)
I'm aware I'm bumping a 1 month old thread. Apologies.

Something I really like in PPMCK (that tool that nobody uses anymore apparently) is the @q command, which allows you to cut a note early by a desired amount of frames. For example, @q1 would cut all notes played by the current track one frame early. This is exactly like the solution with an envelope starting with 0, without the delay.

It's sad that FamiTracker has no quantization control, but that's how trackers are designed.
Re: Mindboggingly simple way to control legato (ftm inside)
by on (#203324)
Jarhmander wrote:
Something I really like in PPMCK (that tool that nobody uses anymore apparently) is the @q command, which allows you to cut a note early by a desired amount of frames. For example, @q1 would cut all notes played by the current track one frame early. This is exactly like the solution with an envelope starting with 0, without the delay.

It's sad that FamiTracker has no quantization control, but that's how trackers are designed.

FamiTracker has the S0x effect, which cuts a note x frames after the start of a row. For example, if the current "speed" is 7 frames per row (F05), S05 will cut it two frames early. The G0x effect, on the other hand, starts a note x frames late. Impulse Tracker and OpenMPT have the same effects but name them SCx (early cut) and SDx (delay). Or you can make a volume envelope that cuts after a particular number of frames, such as 9 6 5 5 5 0.

Pently has a few similar features.

  • Pently 1 has "detached", an instrument setting that cuts all notes played on that instrument one half row early. It can be heard in the cover of "Leck mich im Arsch" in the Thwaite OST, as well as in several sample tracks included with the source distribution.
  • Pently 3 (Thwaite and Zap Ruder) introduced attack envelopes in imitation of FamiTracker volume, duty, and arpeggio envelopes. If an instrument's sustain volume is 0, it will stop when the attack envelope completes. Setting volume 9 6 5 5 5 0 on an instrument makes all its notes 5 frames long.
  • Pently 4 (RHDE) introduced grace notes, a generalization of S0x and G0x. A row's duration can be set in frames instead of fractions of a whole note using the 1g through 9g durations. The following row plays for the remainder of the original row. To play a note that cuts early, use f#4g r8, which plays an F# for 4 frames before cutting it and lasts a total of an eighth note. To start a note late, use w4g f#8, which waits four frames and then plays an F#, taking a total of an eighth note. It's called a grace note because acciaccatura happens if you make both events notes instead of waits or rests.