Hi, all,
I’m writing an article for this year’s ICLC conference and have a question: In Tidal, would it be possible to put a fraction or a variable inside a control pattern? I’d like to be able to do this:
d1 $ freq "440*4" # s "superfm" |* freq "1 1.2 1.5 0.8888888888888888"
...but instead express the last three values as fractions - something like this:
d1 $ freq "440*4" # s "superfm" |* freq "1 (6/5) (3/2) (8/9)"
--but this doesn't work, nor if I try to substitute the fractions with variables:
let ratio65 = 1.2
ratio32 = 1.5
ratio89 = 0.8888888888888888
d1 $ freq "440*4" # s "superfm" |* freq "1 ratio65 ratio32 ratio89"
Would I have to somehow define these values as floats before I can proceed?
Thanks!
SpacepersonJ
you might try something like inhabit
, although i bet you'd have to explicitly define all your custom names...it wouldn't be dynamic if you changed the fraction value without changing your inhabit
def first.
Hola @yecto ,
You could do it with inhabit.
mychords = inhabit [("hola", "[0,4,2]" :: Pattern Double),
("hello", "[0,5,7,12]")
]
d1 $ n (mychords "hello hola") # s "superpiano"
You have to use :: Pattern Double to tell haskell what kind of pattern you're making, but you only have to do that on one of the values, it can work out the rest.
1 Like
yaxu
19 August 2021 19:06
3
Hi @SpacepersonJ , this should work:
d1 $ freq "440*4" # s "superfm" |* freq "1 6%5 3%2 8%9"
In mininotation, %
denotes a ratio (/
manipulates time)
8 Likes
Whhoooaaa! Didn't know about that, and don't know how I didn't see that into the parser code.
That will change my flow a lot! Thanks
1 Like
Thanks, all!
@yaxu - thanks for the tip. The % trick didn't work, though - I got this message:
Error in pattern: Syntax error in sequence:
"1 6%5 3%5 8%9"
^
unexpected '%'
expecting float, "'", "w", "h", "q", "e", "s", "t", "f", rest, "[", "{", "<", "." or end of input
Is this a new feature? I haven't upgraded TC in a bit...
Thanks again,
SPPJ
i think it's 1.4.8 onwards ?
Add ratio shorthand to floating point patterns @yaxu
# TidalCycles log of changes
## 1.7.8 - Ayatakedai
* Add pattern id to patterns as _id_, and send it with /code/highlights
## 1.7.7 - Caramel wafer
* Support hosc 0.19 in test suite @yaxu
## 1.7.6 - Tunnocks
* Fix dot shorthand in int patterns so floating point numbers raise an error @ndr-brt
* Support factors in ratio shorthand for rational patterns @ndr-brt
* support hosc 0.19 @yaxu
## 1.7.5 - Dalbeattie
* Minor change to _splice so that it respects if the speed parameter was already declared @onthepeakofnormal
* Some tests for chords @cleary
* Remove direct semigroups dependency @yaxu
* Derive functor for pattern @yaxu
* Handle negative ratio shorthands for rationals @ndr_brt
* drawLine - draw non-events with periods @yaxu
This file has been truncated. show original
1 Like
Sorry it took so long to reply - I had a bit of trouble updating Tidal.
Wow - the ratio shorthand is incredible!!!! Thanks so much, Yaxu!!!
SPJ
1 Like