Ferramentas do usuário

Ferramentas do site


projetos:musichacking:inicio

Diferenças

Aqui você vê as diferenças entre duas revisões dessa página.

Link para esta página de comparações

Ambos lados da revisão anterior Revisão anterior
Próxima revisão
Revisão anterior
Próxima revisão Ambos lados da revisão seguinte
projetos:musichacking:inicio [2018/02/17 16:29]
phil [Próximo Encontro]
projetos:musichacking:inicio [2018/07/11 01:46]
phil [Encontros Passados]
Linha 37: Linha 37:
  
  
-===== Encontros Passados =====+Codigo pra notas randomicos : 
 + 
 +<code> 
 + 
 +--[[ 
 +name: croissant 
 +description: MIDI processor VST/AU for Protoplug.  
 +I'm going to create a library that emulates the functionality I use from Sonic-Pi for generative / algorithmic music.  
 +Starting with the ring (cyclic array) data-structure. 
 +author: [email protected] 
 +--]] 
 + 
 +require "include/protoplug" 
 + 
 +local blockEvents {} 
 + 
 + 
 + 
 +function ring(ns)  
 + local count 
 + for _ in pairs(ns) do count count + 1 end 
 + return { 
 + notes ns, 
 + noItems count, 
 + current 0,  
 + choose function(self)  
 +math.random(self.noItems) 
 +self.notes[r] 
 + return x 
 + end, 
 + tick function(self) 
 + if (self.current > self.noItems-1) then 
 + self.current = 0 
 + end 
 + self.current = self.current + 1  
 + return self.notes[self.current] 
 + end 
 + }  
 +end 
 +  
 +local scale = ring({0, 3, 7, 11, 12, 17}) 
 +local off_buffer = {} 
 + 
 +function plugin.processBlock(samples, smax, midiBuf) 
 + blockEvents = {}  
 + for ev in midiBuf:eachEvent() do 
 + if ev:isNoteOn() then 
 + local root = ev:getNote()  
 + local note = root + scale:choose() 
 + off_buffer[root] = note 
 + play(ev:getChannel(),note,ev:getVel()) 
 + elseif ev:isNoteOff() then 
 + local note = off_buffer[ev:getNote()] 
 + if not note == nil then 
 + play_off(ev:getChannel(),note) 
 + end 
 + end  
 + end 
 + -- fill midi buffer with prepared notes 
 + midiBuf:clear() 
 + if #blockEvents>0 then 
 + for _,e in ipairs(blockEvents) do 
 + midiBuf:addEvent(e) 
 + end  
 + end 
 +end 
 + 
 +function play(chan,note,vel) 
 + local newEv = midi.Event.noteOn(chan,note,vel) 
 + table.insert(blockEvents, newEv) 
 +end 
 +  
 + 
 +function play_off(chan,note) 
 + local newEv = midi.Event.noteOff(chan,note) 
 + table.insert(blockEvents, newEv) 
 +end 
 + 
 +</code> 
  
 === MusicHacking #24 : web_audio === === MusicHacking #24 : web_audio ===
projetos/musichacking/inicio.txt · Última modificação: 2023/11/13 23:30 por phil