Created
February 21, 2021 19:45
-
-
Save pLabarta/daa4756469619034c883a3ec1d078516 to your computer and use it in GitHub Desktop.
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
d2 >> play("-",dur=PRand([0.25,0.5,0.25,0.5,1])).stop() | |
d1.reset() >> play("X ",dur=0.125,sample=2) | |
d1.stop() | |
d7 >> play(" *",sample=3).stop() | |
b1.reset() >> star(PWalk(1), dur=PSum([6,8],4),amp=0.6,oct=5, drive=0.06, | |
formant=notalways([0,2]),chop=0) | |
Clock.bpm = int(Clock.bpm/2) | |
b1.stop() | |
d3.reset() >> play("u", rate=2,dur=PSum(3,4),pshift=var([0,2,3,4],4) | |
,formant=0 | |
,mix=0.9 | |
,room=0.9) | |
p1.reset() >> play(P["|x4|{[ |x5|] }|o7| "][:3]|P["rr|r3|r"][:1], lpf=1777,amp=0.3).stop() | |
chords = var([0,2,5,7][:4],2) | |
z2.reset() >> piano(chords,dur=PDur([8],8), | |
oct=(5,6), | |
echo=0.25,amp=var([0.8,0],[6,0]), | |
lpf=linvar([333,1777],16)).stop() + (0,2,5) | |
bp >> play("{b}", dur=PRand([0.5,0.25]),amp=P[0,0,0,PRand(1)]*0.7,sample=0,pshift=0).stop() | |
clone(z2,z3,blip) | |
z3.amp=P[0,PRand(1),0,PRand(0)]*0.7 | |
z3.delay=(0) | |
z3.oct=[5,5,PRand([4,5])]36 | |
z3.sus=0.2 | |
z3.fmod=10 | |
z3.chop=0 | |
z3.echo=(0,0.25,0.5) | |
z3.pan=(0,[-1,1]) | |
z3.drive=(0,linvar([0.02,0.05],16)) | |
clone(z2,b5,bass) | |
b5.dur=PSum(3,4) | |
b5.oct=5 | |
b5.stop() | |
c1 >> play(" * ",dur=1,amp=1) | |
def clone(original, player, synth): | |
player.reset() >> synth() | |
for arg in original.__dict__['attr'].keys(): | |
setattr(player,arg,original.__dict__['attr'][arg]) | |
Clock.bpm=120 | |
Scale.default="minorPentatonic" | |
Server.add_forward("192.168.0.104", 7777) | |
import requests | |
import pyphen | |
pyphen.language_fallback('es_ES_variant1') | |
dic = pyphen.Pyphen(lang='es') | |
dic_en = pyphen.Pyphen(lang='en') | |
def esVocal(texto): | |
return texto in "aeiouáéíóú" | |
def findSmallers(silabas): | |
smallers = -1 | |
min = 1000000 | |
for i in range(len(silabas)-1): | |
if min > len(silabas[i]) + len(silabas[i+1]): | |
min = len(silabas[i]) + len(silabas[i+1]) | |
smallers = i | |
return i | |
def silabas_word(text): | |
return list(filter(lambda x : len(x) > 0, dic.inserted(text).replace(" ", "").split("-"))) | |
def silabas_sentence(sentence): | |
sentence = sentence.lower().replace(".","").replace(",","") # limpio un toque el string | |
return sum([silabas_word(word) for word in sentence.split()],[]) | |
def incrementar(notas,inc): | |
return list(map(lambda x: x+inc,notas)) | |
def length(chords,dur): | |
return sum([ dur[i%len(dur)] for i in range(len(chords))]) | |
c3.reload() | |
def choirProgression(chords,letra="la",dur=[1],model=None,octave=5): | |
if model is None: | |
voice(chords,lyrics=letra,dur=dur,file='c1',octave=octave) | |
voice(incrementar(chords,2),lyrics=letra,dur=dur,file='c2',octave=octave) | |
voice(incrementar(chords,4),lyrics=letra,dur=dur,file='c3',octave=octave) | |
else: | |
voice(chords,lyrics=letra,dur=dur,file='c1',octave=octave,model=model) | |
voice(incrementar(chords,2),lyrics=letra,dur=dur,file='c2',octave=octave,model=model) | |
voice(incrementar(chords,4),lyrics=letra,dur=dur,file='c3',octave=octave,model=model) | |
def coroRobot(texto,chords=[0],dur=[4],oct=5): | |
texto = " ".join(silabas_sentence(texto)) | |
chords = chords*int(len(texto.split())/len(chords)) | |
choirProgression(chords,letra=texto,dur=dur,octave=oct) | |
def coro(dur,reverb=True,formant=0,amp=1): | |
if reverb: | |
mix=0.9 | |
room=0.9 | |
else: | |
mix=0 | |
room=0 | |
c1.reload() | |
c1 >> loop('c1',P[0:dur],amp=amp,mix=mix,room=room,formant=formant) | |
c2.reload() | |
c2 >> loop('c2',P[0:dur],amp=amp,mix=mix,room=room,formant=formant) | |
c3.reload() | |
c3 >> loop('c3',P[0:dur],amp=amp,mix=mix,room=room,formant=formant) | |
def pararCoro(): | |
c1.stop() | |
c2.stop() | |
c3.stop() | |
def voice(chords,lyrics,dur,file,octave): | |
data = {"notes": chords, | |
"lyrics": lyrics, | |
"dur": dur, | |
"tempo": Clock.bpm, | |
"lang": "la", | |
"octave": octave, | |
"scale": list(Scale.default.semitones)} | |
api = 'http://localhost:5000/voice' | |
r = requests.post(api, json=data) | |
print(r.status_code) | |
open(FOXDOT_LOOP +'/'+file+'.wav','wb').write(r.content) | |
def spell(lyrics): | |
#pt = [2/6]*4 + [4/6] + [rest(2)] | |
pt = [2/6]*6*4 | |
data = {"notes": [0], | |
"lyrics": lyrics, | |
"dur": pt, | |
"tempo": 120, | |
"lang": "la", | |
"octave": 5, | |
"scale": list(Scale.default.semitones)} | |
api = 'http://localhost:5000/voice' | |
r = requests.post(api, json=data) | |
print(r.status_code) | |
open(FOXDOT_LOOP +'/spell.wav','wb').write(r.content) | |
def spread(values,level=1,tt=var): | |
intervals = [32,32,64,64] | |
return tt(values,[x*level for x in intervals]) | |
def intermitent(values,tt=var): | |
intervals = [14, 2, 7, 1, 8, 8, 28, 4] | |
random.shuffle(intervals) | |
return tt(values,intervals) | |
def notalways(order=1,level=3,tt=var): | |
if order == 1: | |
pattern = [0, 1] | |
else: | |
pattern = [1, 0] | |
return tt(pattern, 4**level) | |
lyrics = "Plato dicit et magnum principem comidas decrevit. Alternatives ad mutare magis versions" | |
spell(lyrics) | |
v1.reset().reload() >> loop("spell",var(P[3:4],1),dur=[1], | |
amp=notalways(order=0)*2, | |
chop=intermitent([5]), | |
glide=4).stop() | |
v1.stop() | |
v2.reset().reload() >> loop("spell",P[16:32], | |
amp=notalways(order=1,level=2)*2, | |
chop=intermitent([3,4]), | |
glide=7) | |
load_startup_file() | |
v2.stop() | |
acordes = [0] | |
choirProgression(list(chords),letra="live coding",dur=[4],octave=5) | |
coro(32,reverb=True,formant=var([0,2,3],[4]),amp=0.3) | |
pararCoro() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment