This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# this code is to get the CRC8 from a series of bytes we give | |
import crc8 | |
# global variable | |
hash | |
# byte we want to calculate the CRC on to |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
#useful link: https://stackoverflow.com/questions/55596557/os-read0-vs-sys-stdin-buffer-read-in-python | |
# use the program piping it some other byte-outputting software. | |
# Es. | |
# mosquitto_sub -h 192.168.1.4 -t \# | ./prettyPrint_incoming_bytes.py | |
import os | |
HOWMANYBYTES = 32 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import time | |
while 1: | |
secondsSinceEpoch = int( time.time() ) | |
# how many seconds in a day? 24 * 60 * 60 | |
secondsSinceDayStart = secondsSinceEpoch % 86400 | |
#calculate seconds in a minute |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Do a rountine will continue having effetcs | |
// on the future if we stop it? | |
// Here we define a routine which will be launched by the main one | |
// It will wait 5 secs before playing a tone | |
( | |
~r2 = Routine({ | |
var delay = 0.125; | |
var initialTime, elapsedTime; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// load stone samples /////////////////////////////////////////////////////////////////// | |
~sample = Buffer.read(s, "/home/nicola/Musica/sfx/CC0/stone_on_stone_dragging/_exports/dragged_stone_02.wav"); | |
// test | |
{PlayBuf.ar(1, ~sample, doneAction:2)}.play; | |
( | |
// GRAIN PLAYER | |
// a synth to play buffers in a granular fashion | |
SynthDef(\texture_generator, { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
b = Buffer.read(s, "path/to/your/file.wav"); | |
// even if you explicitly set the BufRd loop argument to 0 | |
// The sound will loop anyway because of the fact Phasor is a periodic function | |
( | |
SynthDef(\test, { | |
|buf, trig=1, rate=1| | |
var sig, ph; | |
ph = Phasor.ar(trig, rate*BufRateScale.ir(buf), 0, BufFrames.ir(buf)); | |
sig = BufRd.ar(2, buf, ph, interpolation:2); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# a test to convert binary numbers | |
# In order to obtain the two complement (TC) of a number N: | |
# 1. You must first negate all bits (255 - N); | |
# 2. You must then add one to the obtained number | |
# This is the formula | |
# TC = 255 - N + 1 | |
# So in order to obtain back the number N | |
# having the TC number we shuold invert that formula. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Trying to procedurally synthetise a violin, | |
// I eventually came out with the "Farfisa organ like sound | |
( | |
SynthDef(\violin, { | |
| midinote = 60 | | |
var sig = VarSaw.ar( | |
midinote.midicps, | |
width:LFNoise2.kr(1).range(0.2, 0.8)*SinOsc.kr(5, Rand(0.0, 1.0)).range(0.7,0.8))*0.25; | |
Out.ar(0, sig); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#N canvas 171 94 395 130 10; | |
#X obj 219 69 metro 125; | |
#X obj 169 93 tabwrite~ \$0-A; | |
#N canvas 0 22 450 278 (subpatch) 0; | |
#X array \$0-A 2051 float 2; | |
#X coords 0 1 2050 -1 140 100 2 0 0; | |
#X restore 10 10 graph; | |
#X obj 219 48 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 1 | |
1; | |
#X obj 169 10 inlet~; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This synth def is not so efficient due to the fact | |
// we are creating 3 different delay line instead of making | |
// three different read from a single one (as can be done | |
// with [delwrite~] and [delread~] objects in PD). | |
( | |
SynthDef(\test, { | |
var sig, dly1, dly2, dly3; | |
sig = SinOsc.ar(LFTri.kr(0.25,mul:1000, add:2000)) * 0.1; | |
dly1 = DelayN.ar(sig, 3, 0.3) * 0.5; | |
dly2 = DelayN.ar(sig, 3, 0.6) * 0.25; |
NewerOlder