Firmware: Improve swing?
Moderators: Altitude, adafruit_support_bill, adafruit, phono, mome rath

Firmware: Improve swing?

by mario1089 on Wed Oct 24, 2012 1:04 am

I noticed the swing is pretty lousy, and reading the code it was easy to see why: Swing Depths are 50%, 100% (straight triplets), 150%(?!), 200%(!?!?), 250%(!?!?!?) - so we have one useful depth, and for me personally it is still too high. It`s obviously not easy to improve in the existing processing concept - but let`s discuss how it would be possible..

I think - for swung events - we should instead of calling dispatch_note_on/off use another timer (or the existing 1ms timer), queue the swung event by the right time and then on timer-callback, call the queued dispatching. Agree? If yes, may I ask how that would look code-wise, basically?
mario1089
 
Posts: 196
Joined: Wed Sep 19, 2012 7:11 am

Re: Firmware: Improve swing?

by antto on Wed Oct 24, 2012 6:16 am

i don't understand the timer-related stuff, so no idea about that

but what you describe won't work in slaved mode, unless you put yet another pile of code to fix the issues there

the existing swing is based on the dinsync clock, which is essentially 48ticks per quarter note
thus you have 12 ticks per step
so normally you put the NoteON processing on tick 0, and the NoteOFF on tick 6
shuffle basically messes with these two, changing them for each step
and thus, you cannot have a "fine" shuffle adjustment, BUT it works in slaved mode no problem
We are here too: irc.freenode.net >>> #x0xb0x
..:: c0nb0x v1.00 ::.. http://forums.adafruit.com/viewtopic.php?f=7&t=29282 (new control app - win/osx)
VCO Tuning: http://forums.adafruit.com/viewtopic.php?f=12&t=24759 (do it the EASY way)
User avatar
antto
 
Posts: 1361
Joined: Thu Apr 15, 2010 2:21 pm
Location: 127.0.0.1

Re: Firmware: Improve swing?

by mario1089 on Wed Oct 24, 2012 8:46 am

Yes, I know exactly how it works in the existing code. It`s actually 24 PPQ, and the noteOff and the NoteOn are both processed at pulse 0,6,12,18. Now for swung notes the 6 and the 18 are moved back 1,2,3,4 or 5 pulses - for 1 pulse back resulting in 50% swing depth, for 2 pulses back 100% (1/3 of a 1/16 = exactly on the position of a 1/32 triplet = 100%swung), 150%, and so on.

So as this idea does not allow for fine adjust, the concept has to be rewritten. My idea is to not send the noteOn / noteOff directly for swung notes, but 1) store the note as pendingSwingEvent, 2) set a millisecond timeout Variable timeToPendingEvent = SWINGTIME (calculated from tempo and swing depth wanted) 3) watch a timer to decrement timeToPendingEvent or something similar 4) finally send the pending event when timeToPendingEvent==0, or when the timer calls its timeout().

My question would be if someone feels able to drop some lines about timers in the xoxbox, or how I could achieve that or any other help.

A solution is to put a shuffleBox inside the machine, but I dont like that, as it will introduce extra latency (5ms? 10ms?) I assume, so would be much cooler and cheaper for all of us to find a onboard solution..

Thanx.

Btw, MIDI triggering mode (with scale corrected transpositions, latch key, stop key, pattern select, etc) is kinda finnished and smart randomizer (13 macro commands) also, all works brilliantly good and is nothing but fun. Swing improve is the last thing to achieve for me before I share it..
mario1089
 
Posts: 196
Joined: Wed Sep 19, 2012 7:11 am

Re: Firmware: Improve swing?

by mario1089 on Wed Oct 24, 2012 11:33 am

Issue solved. was easy. fine swing with depth 10%,20%,30%,..,100% almost done.
mario1089
 
Posts: 196
Joined: Wed Sep 19, 2012 7:11 am

Re: Firmware: Improve swing?

by antto on Wed Oct 24, 2012 6:51 pm

midisync is said to be "24ppqn" but it's 24 ticks per beat, not pulses
dinsync is commonly known as 24ppqn too, but this time it is 24 pulses, each having 2 distinctive moments so it's actually 48 ticks per beat

and your description of shuffle is a bit odd to me, and the percentage you calculated.. O_o
for each 2 steps, every first one becomes longer, and thus every second one becomes shorter (and is delayed due to the extension of the first one)
so the notes and gates look like this:
Code: Select all | TOGGLE FULL SIZE
Normal: 6,6 - 6,6
|On   |Off  |On   |Off
------______------______
7,7 - 5,5
-------_______-----_____
8,8 - 4,4
|On     |Off    |On |Off
--------________----____
---------_________---___
----------__________--__


the idea about timers might cost enough cpu processing to make it equivalently slow as a latency from a external shuffle box
btw, the stock x0x firmware is already quite unstable as far as internal sync goes
the 303 has a real (analog) square wave oscillator used as a clock, so no matter if the cpu is too busy or not - the internal clock is stable
for good or bad, the x0x uses a digital one :?
We are here too: irc.freenode.net >>> #x0xb0x
..:: c0nb0x v1.00 ::.. http://forums.adafruit.com/viewtopic.php?f=7&t=29282 (new control app - win/osx)
VCO Tuning: http://forums.adafruit.com/viewtopic.php?f=12&t=24759 (do it the EASY way)
User avatar
antto
 
Posts: 1361
Joined: Thu Apr 15, 2010 2:21 pm
Location: 127.0.0.1

Re: Firmware: Improve swing?

by mario1089 on Thu Oct 25, 2012 1:00 am

I guess you are right about the 24/48 thing, but it may be a matter of perspective.

the percentages I mentioned are right. 100% swing commonly is refered to every 2nd 16th note being on the position of the 3rd triplet = moved back a 1/3 of a 1/16 note. As it was it was useful only for some use cases, but not for the subtle ones and not when used at higher tempos, like >130. I was very disappointed when trying it out.

anyway, I got it right now, and it works so much nicer that way, sounds exactly like a swing depth knob in a soft-seq - with 10 steps instead of continiuos control, though. You`ll see soon and you`ll agree:)

Thanx for discussing this, and big thanx about your advice for MIDI processing, that one was a damn good help - I wouldnt have found that place to add the code on my own so easily, as I know now.
mario1089
 
Posts: 196
Joined: Wed Sep 19, 2012 7:11 am

Re: Firmware: Improve swing?

by pangrus on Fri Oct 26, 2012 2:21 am

Hi everybody,
I am following with interest the latest firmware modifications.
I am very interested in the new swing management, and as I personally do not use tracks but only patterns this new firmware seems promising.
I do not know which firmware has mario1089 used to start the changes, but there is one thing that I use sometimes (with sokkos 1.9) and that I really like. By pressing the ACCENT, SLIDE or REST toghether with DONE you invert the operation of the button and this allows very interesting interactions, especially with the slide.
I hope this feature (or bug) is maintained in the new firmware.
Another key thing is the real time switch to pattern edit mode and the ability to save, without stopping.
I look forward to try the the new firmware.
User avatar
pangrus
 
Posts: 42
Joined: Fri Feb 25, 2011 9:20 am

Re: Firmware: Improve swing?

by mario1089 on Fri Oct 26, 2012 3:17 am

I started with sokkOS2.0 and did not change anything except swing, MIDI sync mode and randomizer/macro functions in pattern-edit-mode. About the 3 buttons, I don`t know:(
I always save without stopping, was that ever not possible?

Release will be tomorrow!
mario1089
 
Posts: 196
Joined: Wed Sep 19, 2012 7:11 am

Re: Firmware: Improve swing?

by mario1089 on Sat Oct 27, 2012 3:17 am

Well, I have to admit, my percentages for the old swing were wrong. It`s actaully half: 25%,50%,..125%. Shame on me. But when externally synced the old swing had actually just half the options (see void clock_ticks(); ) - so either 25% or 50%, havent checked which one worked.
Nevertheless, my new code is right, at least.

Cheers!
mario1089
 
Posts: 196
Joined: Wed Sep 19, 2012 7:11 am