carrierdown / mutateful

Add-on for Ableton Live that enables live coding functionality fully integrated into Live's session view.
GNU General Public License v3.0
406 stars 13 forks source link

REQUEST FOR INFORMATION. Durations greater than a quaver #9

Closed twobob closed 5 years ago

twobob commented 5 years ago

How does one express a crotchet, minim, semibreve and moreover multiples of those for durations?

I tried the obvious "1" for a crochet and got an error about mixing formats. Rather than report that (annoyingly) as a bug I am checking how would one would express it.

I am assuming it must be 1/1 for crotchet, 2/1 minim, 4/1 semibreve, 8/1 breve, 16/1 longa, et cetera.

Lets say Take is the command. How would one say
Start at "4 bars and 2 beats" and take "2 bars and 3 beats"

is it 9/2 5/2 ?

If so, that's pretty tortuous for the average user probably, I am not even sure the maths in that example would be correct and obviously some really fiddly values could result. :\ And that was a really easy example :\

perhaps some sort of shorthand? Maybe check for two periods in the string and do a Bars.Beats.Ticks conversion? Live works like that internally AFAIK, at least as far as the average user is concerned. Possibly request for enhancement?

twobob commented 5 years ago

Also durations with a denominator over 9 don't work. Such as 12/2 or 11/1

Received 2 clips and formula: [0] shuf -by [1] take 2/1 10/1 Error: Unrecognized input at position 28:\r\n shuf -by [1] take 2/1 10/\r\n ^

That might be a bug

Also the loop size of the resulting clip seems to be short by exactly the original offset value, which might be a bug.

carrierdown commented 5 years ago

Yep, the idea is that you should be able to specify bars, but this isn’t implemented properly yet. It’s parsed as a number where it expects a decimal value. Will have to tweak the parser a bit to allow for this to work like it should:)

-Knut

  1. apr. 2019 kl. 15:45 skrev _ notifications@github.com:

hmm so durations with a denominator over 9 don't work.

Received 2 clips and formula: [0] shuf -by [1] take 2/1 10/1 Error: Unrecognized input at position 28:\r\n shuf -by [1] take 2/1 10/\r\n ^

That might be a bug

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

carrierdown commented 5 years ago

Implementing a bars.beats.ticks type of format is also a possibility. Will get back to you on this when I have time to spare.

-Knut

  1. apr. 2019 kl. 15:45 skrev _ notifications@github.com:

hmm so durations with a denominator over 9 don't work.

Received 2 clips and formula: [0] shuf -by [1] take 2/1 10/1 Error: Unrecognized input at position 28:\r\n shuf -by [1] take 2/1 10/\r\n ^

That might be a bug

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

twobob commented 5 years ago

I'm just struggling with the concept of a decimal. Because I can't pass 12.75 or something directly

Received 2 clips and formula: [0] shuf -by [1] take 2/1 12.75 Error applying formula: Invalid option values: Values for a single option need to be of the same type. Received 2 clips and formula: [0] shuf -by [1] take 5.25 12.75 Error applying formula: Invalid combination. Token of type Decimal and property of type Decimal[] are not compatible. formula: [0] shuf -by [1] take 5.25 Fails silently.

I guess I'm just not quite there yet, I did look through the conversion code.

carrierdown commented 5 years ago

Specifying that directly should also be possible, so several fixes are needed here. I think I agree with you on all counts, though :)

-Knut

  1. apr. 2019 kl. 16:32 skrev _ notifications@github.com:

I'm just struggling with the concept of a decimal. Because I can't pass 12.75 or something directly

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

twobob commented 5 years ago

Ah good to know. thanks. I will note any tiny things like silent fails on the Take command to a separate issues and try to look at them as time allows, like yourself.

twobob commented 5 years ago

Okay I see the issue in the parser with > 1 digit numerator values is simply an indexOf issue. fair enough the b.b.t format thing seems doable, I shall look at it at some point then.

twobob commented 5 years ago

In terms of "discovering the token" properly

 private bool IsMusicalDivision(out int SlashIndexInBuffer, int pos)
        {
           int NextSpace = pos;
            SlashIndexInBuffer = 0;
            string TestTheString = string.Empty;
            while (!(NextSpace == Buffer.Length))
            {
                if (Char.IsWhiteSpace(Buffer[NextSpace]))
                { break; }
                TestTheString += Buffer[NextSpace]; 
                NextSpace++;
                SlashIndexInBuffer = NextSpace - Position - 1;
            }
            string pattern = @"[0-9]+\/[0-9]+";
            Match m = Regex.Match(TestTheString, pattern, RegexOptions.IgnoreCase);
            return m.Success;
}

Obviously the call to that will honour the out like

else if (IsMusicalDivision(out OffsetOfFoundMusicalStart, Position))
{
token = new Token(MusicalDivision, GetRemainingNumericToken(
                Position, OffsetOfFoundMusicalStart), Position);
 }

where OffsetOfFoundMusicalStart is a locally scoped throwaway int.

(or a less pointlessly expansive version) would do the job for detection. But I think that would cover a fix? I'll dig around and see if I can sure up the extant MusicalDivision detection before adding anything new like B B T.

Pattern matching seems relatively robust to offsets, confirmed this gives not insane values. image

carrierdown commented 5 years ago

I'm actually working on doing MusicalDivisions properly now, along with a B.B.T format. Will report back :)

carrierdown commented 5 years ago

Thanks for looking into this. I'm probably going to refactor this section a bit though, and there's also some related parsing-logic which needs to be looked into. Might be I need to add some simple casting mechanics to get the various number formats working properly. It should for instance be possible to specify 12 as a musical value, which would be taken to mean 12 bars.

twobob commented 5 years ago

well. what I have now supports

Received 1 clips and formula: [0] rl 1001/975 rl 1/2

Which will do for now until there is something else. Excited to see what you come up with! Many thanks for your time

carrierdown commented 5 years ago

Great!

carrierdown commented 5 years ago

parsertest Tests are looking good. Don't have time to test today, but have hopefully implemented implicit casting from i.e. number to musicaldivision. Also, parsing of musicaldivisions are now handled properly. Feel free to test if you have time to spare - it's on the branch feature/implicit-cast.

twobob commented 5 years ago

Thanks very much I'll grab it down and have a butchers

carrierdown commented 5 years ago

Just added support for input in the format beats.bars.sixteents (as used in Live) and tightened up casting logic. Not merged to master yet, so feature/implicit-cast is the place to be ;)

carrierdown commented 5 years ago

Now merged to master. Closing this issue :)