Difference between revisions of "binary"

From TidalCycles userbase
Jump to: navigation, search
(Created page with "Type: <source inline>binary :: Pattern Int -> Pattern Bool</source> '''binary''' allows you to express a boolean pattern as a decimal number. For example...")
 
Line 5: Line 5:
 
For example `163` in binary is `10100011`, and so these are equivalent:
 
For example `163` in binary is `10100011`, and so these are equivalent:
  
```
+
<source>
 
d1 $ struct (binary 163) $ sound "clap:4"
 
d1 $ struct (binary 163) $ sound "clap:4"
  
 
d1 $ struct "t f t f f f t t" $ sound "clap:4"
 
d1 $ struct "t f t f f f t t" $ sound "clap:4"
```
+
</source>
  
 
That number can be patterned:
 
That number can be patterned:
```
+
<source>
 
d1 $ struct (binary ("163 63")) $ sound "clap:4"
 
d1 $ struct (binary ("163 63")) $ sound "clap:4"
```
+
</source>
  
 
= binaryN =
 
= binaryN =
Line 20: Line 20:
 
[[Type signature|Type]]: <source inline>binaryN :: Int -> Pattern Int -> Pattern Bool</source>
 
[[Type signature|Type]]: <source inline>binaryN :: Int -> Pattern Int -> Pattern Bool</source>
  
'''binaryN''' lets you specify a number of bits for the pattern. For example `55532` gives the boolean pattern `1101100011101100`:
+
'''binaryN''' lets you specify a number of bits for the pattern. For example <source inline>55532</source> gives the boolean pattern <source inline>1101100011101100</source>:
  
```
+
<source>
 
d1 $ struct (binaryN 16 55532) $ sound "bd"
 
d1 $ struct (binaryN 16 55532) $ sound "bd"
```
+
</source>
  
 
= ascii =
 
= ascii =

Revision as of 22:12, 26 July 2019

Type: binary :: Pattern Int -> Pattern Bool

binary allows you to express a boolean pattern as a decimal number.

For example `163` in binary is `10100011`, and so these are equivalent:

d1 $ struct (binary 163) $ sound "clap:4"

d1 $ struct "t f t f f f t t" $ sound "clap:4"

That number can be patterned:

d1 $ struct (binary ("163 63")) $ sound "clap:4"

binaryN

Type: binaryN :: Int -> Pattern Int -> Pattern Bool

binaryN lets you specify a number of bits for the pattern. For example 55532 gives the boolean pattern 1101100011101100:

d1 $ struct (binaryN 16 55532) $ sound "bd"

ascii

Type: ascii :: Pattern String -> Pattern Bool

Turns characters into 8-bit binary patterns, using their ASCII encoding.