Implementing swing (shuffle)

DSP, Plug-in and Host development discussion.
mistertoast
KVRAF
3404 posts since 15 Sep, 2002

Post Sun Aug 30, 2009 8:43 am

Has there ever been a good thread here on how to implement variable swing? I tried a search, but no luck.

If not, what's a reasonable range for swing? Is the first note in a pair always longer than the second, as most sources seems to say? Should I just mimic the swing of an existing drum machine VSTi?
Swing is the difference between a drum machine and a sex machine.

Leslie Sanford
KVRAF
1597 posts since 4 Dec, 2006

Post Sun Aug 30, 2009 9:13 am

mistertoast wrote:Has there ever been a good thread here on how to implement variable swing? I tried a search, but no luck.

If not, what's a reasonable range for swing? Is the first note in a pair always longer than the second, as most sources seems to say? Should I just mimic the swing of an existing drum machine VSTi?
You could make it variable. For no swing, every 8th note is the same length and is an equal distance from each other. As you increase swing, every other eigth note is pushed forward in time, while make it shorter and making the other eigth note longer.

mistertoast
KVRAF
3404 posts since 15 Sep, 2002

Post Sun Aug 30, 2009 9:34 am

Leslie Sanford wrote:
mistertoast wrote:Has there ever been a good thread here on how to implement variable swing? I tried a search, but no luck.

If not, what's a reasonable range for swing? Is the first note in a pair always longer than the second, as most sources seems to say? Should I just mimic the swing of an existing drum machine VSTi?
You could make it variable. For no swing, every 8th note is the same length and is an equal distance from each other. As you increase swing, every other eigth note is pushed forward in time, while make it shorter and making the other eigth note longer.
OK. Assume I'm swinging 8th notes. Do I internally swing 16th notes within 8th notes?
Swing is the difference between a drum machine and a sex machine.

Leslie Sanford
KVRAF
1597 posts since 4 Dec, 2006

Post Sun Aug 30, 2009 10:04 am

mistertoast wrote:OK. Assume I'm swinging 8th notes. Do I internally swing 16th notes within 8th notes?
I was afraid you were going to ask that question. :hihi:

I don't know. :) I would take a look at various MIDI sequencers and apply their swing algorithms to a set of notes, 16th and otherwise, to see how they handle it.

With my arpeggiator, I ignore the note divsion and simply swing every other note; it doesn't matter to the arp whether they are 8th notes, 16th notes, or whatever. But if I were writing something like a drum machine or sequencer, I'd have to think this through a bit more.

mistertoast
KVRAF
3404 posts since 15 Sep, 2002

Post Sun Aug 30, 2009 10:19 am

Leslie Sanford wrote:
mistertoast wrote:OK. Assume I'm swinging 8th notes. Do I internally swing 16th notes within 8th notes?
I was afraid you were going to ask that question. :hihi:

I don't know. :) I would take a look at various MIDI sequencers and apply their swing algorithms to a set of notes, 16th and otherwise, to see how they handle it.

With my arpeggiator, I ignore the note divsion and simply swing every other note; it doesn't matter to the arp whether they are 8th notes, 16th notes, or whatever. But if I were writing something like a drum machine or sequencer, I'd have to think this through a bit more.
I was afraid you were afraid. :-)

Good idea on looking at MIDI sequencers.
Swing is the difference between a drum machine and a sex machine.

mdsp
KVRian
625 posts since 29 Jul, 2003 from Paris - France

Post Sun Aug 30, 2009 11:47 pm

I once talked with a jazz bass player who told me that he liked to think about swing as micro tempo fluctuations rather than shifts.

take a 8th swing, the first half of the beat is stretched because the tempo slows down and the minimum tempo happen on off-beat 8ths. then the other half of the beat is compressed so that the global tempo doesn't seem to change.

If you think about it that way then it's easy to find how much you need to shift 16th notes within an 8th swing because of the continuous tempo map.

neoxtrope
KVRist
37 posts since 10 May, 2005

Post Mon Aug 31, 2009 12:21 am

I recently created Live groove templates from my Roland TR-909.

I sampled 1/16th rimshots at 96kHz for each of the six shuffle settings running at the slowest tempo. Then I worked out how much each rimshot was offset from where it would be without shuffle.

Turns out that the shuffle of the TR-909 delays each even-numbered 1/16th by 2/96 of a beat for shuffle setting 1, 4/96 for 2, 6/96 for 3, 8/96 for 4, 10/96 for 5 and 12/96 for 6.

Hope this helps.

mystran
KVRAF
5270 posts since 12 Feb, 2006 from Helsinki, Finland

Post Mon Aug 31, 2009 12:29 am

Couldn't you take the linear timescale within the swinged region (say quarter note for 8th swing, or 8th note for 16th swing) and deform it with some curve. Say, to map the first note to 2/3 and the second to 1/3 of the total time, you could use any continuous curve which satisfies f(0)=0,f(1)=1,f(2/3)=0.5 and use that as the deformed time. You could also patch f'(0)=f'(1) to keep the "tempo" continuous and f'(t)>0,t:[0,1] to keep it monotonically advancing (so as not to create situations where you swing so hard as to go back in time). Within those constraints you could then come up with all kinds of different swings..

Plus it should be quite straight forward to put swings on different timescales on top of each other (just mangle the time for each level in recursion) and apply different swings at different beats... and so on. :)
If you'd like Signaldust to return, please ask Katinka Tuisku to resign.

brambos
KVRian
1338 posts since 26 Aug, 2005 from Netherlands

Post Mon Aug 31, 2009 1:13 am

mistertoast wrote:
Leslie Sanford wrote:
mistertoast wrote:Has there ever been a good thread here on how to implement variable swing? I tried a search, but no luck.

If not, what's a reasonable range for swing? Is the first note in a pair always longer than the second, as most sources seems to say? Should I just mimic the swing of an existing drum machine VSTi?
You could make it variable. For no swing, every 8th note is the same length and is an equal distance from each other. As you increase swing, every other eigth note is pushed forward in time, while make it shorter and making the other eigth note longer.
OK. Assume I'm swinging 8th notes. Do I internally swing 16th notes within 8th notes?
How I've been doing it ever since HammerHead (and which sounds right to my ears) is by swinging 8th notes, and simply dividing each 8th note in two equal parts to get the corresponding 16th notes.

mistertoast
KVRAF
3404 posts since 15 Sep, 2002

Post Mon Aug 31, 2009 6:23 am

Wow. Some great answers here. I was thinking a curve, but I'm willing to try anything.

The idea of going back in time is strangely compelling, though. I must do that.
Swing is the difference between a drum machine and a sex machine.

bvesco
KVRist
150 posts since 25 Jan, 2008 from Oregon, USA

Post Mon Aug 31, 2009 10:18 am

brambos wrote:each 8th note in two equal parts to get the corresponding 16th notes.
Yay Hammerhead! Nice work on that btw, I still use it every time I need a click to practice with. I made a custom sound bank that uses DFH samples :) Been using Hammerhead ever since the stomper mailing list days and to this day recommend it to people all the time.

As far as evenly dividing each 8th, I've never questioned the approach of HH and that sounds fine. Just wanted to point out that the rhythm it will create if you have four 16ths in a row is that of two 8th triplets followed by two 16th triplets.

Let's see how good my ASCII skills are...

Code: Select all

      3
 -----------
 |   |   |-|
 |   |   | |
o   o   o o

mistertoast
KVRAF
3404 posts since 15 Sep, 2002

Post Mon Aug 31, 2009 10:31 am

Yeah I remember Hammerhead, too. Think I found it through a discussion link on Maz Sound. :-)
Swing is the difference between a drum machine and a sex machine.

MadBrain
KVRian
950 posts since 1 Dec, 2004

Post Mon Aug 31, 2009 3:07 pm

Typical values for swing are between 50% and about 70%, and swing is canonically defined as 66%, although weaker swing sounds good too. One weird property is that swing applies to anything divided in 8ths, but triplets and 16ths tend not to be affected (since the 3rd sub-beat of the triplet corresponds to the swinged 8th beat, and 16ths tend to sound better straight). Smaller divisions even tend to be grace notes or fast scales or arpeggios I think.

I'm not sure how you'd apply that algorithmically, probably depends on the type of data... The traditionnal way of doing it in a tracker is to make a small speed change pattern, typically something like 6 ticks, 6 ticks, 3 ticks, 3 ticks, 6,6,3,3,6,6,3,3,etc..., and copy that all over the song. This has the advantage of making triplets easy to input (because you can input them as xxx.xxx.xxx.xxx.) at the cost of making smaller divisions such as 16ths harder. Another possibility would be apply swing to measures with 8ths but not to measures with smaller divisions. Or you could apply some sort of quantizing that would move 8th notes to swing 8ths, but leave triplets unchanged.

mistertoast
KVRAF
3404 posts since 15 Sep, 2002

Post Mon Aug 31, 2009 4:26 pm

MadBrain wrote:Typical values for swing are between 50% and about 70%, and swing is canonically defined as 66%, although weaker swing sounds good too. One weird property is that swing applies to anything divided in 8ths, but triplets and 16ths tend not to be affected (since the 3rd sub-beat of the triplet corresponds to the swinged 8th beat, and 16ths tend to sound better straight). Smaller divisions even tend to be grace notes or fast scales or arpeggios I think.

I'm not sure how you'd apply that algorithmically, probably depends on the type of data... The traditionnal way of doing it in a tracker is to make a small speed change pattern, typically something like 6 ticks, 6 ticks, 3 ticks, 3 ticks, 6,6,3,3,6,6,3,3,etc..., and copy that all over the song. This has the advantage of making triplets easy to input (because you can input them as xxx.xxx.xxx.xxx.) at the cost of making smaller divisions such as 16ths harder. Another possibility would be apply swing to measures with 8ths but not to measures with smaller divisions. Or you could apply some sort of quantizing that would move 8th notes to swing 8ths, but leave triplets unchanged.
I thought it was just shuffle that was defined as 2/3, with swing being variable. Wikipedia: http://en.wikipedia.org/wiki/Swung_note
Swing is the difference between a drum machine and a sex machine.

brambos
KVRian
1338 posts since 26 Aug, 2005 from Netherlands

Post Tue Sep 01, 2009 1:12 am

bvesco wrote:As far as evenly dividing each 8th, I've never questioned the approach of HH and that sounds fine. Just wanted to point out that the rhythm it will create if you have four 16ths in a row is that of two 8th triplets followed by two 16th triplets.

Let's see how good my ASCII skills are...

Code: Select all

      3
 -----------
 |   |   |-|
 |   |   | |
o   o   o o
Interesting idea - which I wasn't criticizing at all btw. I just chimed in to say that the OP's question could be answered with a supersimple answer. And since I like supersimple things... :D

Return to “DSP and Plug-in Development”