Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ the default mappings, along with the controls available on the grid, are designe

- **amp [a/b/c]**: the amplitude or volume of the three sine waves in the synth voice

by default, the amplitutes are:
by default, the amplitudes are:

| a | b | c |
| - | - | - |
Expand Down
2 changes: 1 addition & 1 deletion lib/Engine_Orgn.sc
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Engine_Orgn : CroneEngine {
var <fxBus;
var <fx;

var <maxNumVoices = 16;
var <maxNumVoices = 4;

var <ops = 3;
var <tf;
Expand Down
48 changes: 47 additions & 1 deletion lib/midi.lua
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,55 @@ m.event = function(data)
if msg.type == "note_on" then
--TODO: velocity range params
orgn.noteOn(msg.note, mu.note_num_to_freq(msg.note), ((msg.vel or 127)/127)*0.2 + 0.85)
elseif msg.type == "note_off" then
elseif msg.type == "note_off" then
orgn.noteOff(msg.note)
end
end


--osc note code
local function osc_note_off(note, sleep_time)
clock.sleep(sleep_time or 0.25)
orgn.noteOff(note)
end

local function on_osc_event(path, args, from)
if path == "/play_note" and orgn then
orgn.noteOn(args[2], mu.note_num_to_freq(args[2]), (args[3] / 127)*0.2 + 0.85)
clock.run(osc_note_off,args[2], 0.25)
elseif path == "/note_on" and orgn then
local midi_note = args[2]
local vel = args[3]
orgn.noteOn(midi_note, mu.note_num_to_freq(args[2]), (args[3] / 127)*0.2 + 0.85)
-- Grab the chosen nb voice's player off your param
local player1 = params:lookup_param("nb_voice1"):get_player()
local player2 = params:lookup_param("nb_voice2"):get_player()
player1:note_on(midi_note, vel)
player2:note_on(midi_note, vel)
print('note on', midi_note, vel)

elseif path == "/note_off" and orgn then
local midi_note = args[2]
orgn.noteOff(midi_note)
-- Grab the chosen nb voice's player off your param
local player1 = params:lookup_param("nb_voice1"):get_player()
local player2 = params:lookup_param("nb_voice2"):get_player()
player1:note_off(midi_note)
player2:note_off(midi_note)
print('note off', midi_note)
elseif path == "/all_off" and orgn then
print("all off")
for i=0,100 do engine.noteOff(i) end
end
end



local function osc_connect()
print("osc connect!!!")
osc.event = on_osc_event
end
osc_connect()

return m

9 changes: 8 additions & 1 deletion lib/orgn.lua
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -167,10 +167,17 @@ local pitch = {
off = 0,
mod = 0,
oct = 0,
p = 2,
update = function(s)
engine.pitch((2^(s.off) * (2^s.oct)) + s.mod/2)
s.p = (2^(s.off) * (2^s.oct)) + s.mod/2
engine.pitch(s.p)
end
}

orgn.get_pitch = function ()
return pitch.p
end

local lfo = {
rate = 0.4, mul = 0, phase = 0, quant = 0.05,
shape = function(p) return math.sin(2 * math.pi * p) end,
Expand Down
69 changes: 40 additions & 29 deletions lib/ui.lua
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,29 @@ function App.grid(args)
local vel = math.random()*0.2 + 0.85

local hz = 440 * tune.hz(k.x, k.y, nil, nil, params:get('scale_preset'))
local midi_note = mu.freq_to_note_num (hz*orgn.get_pitch())

if add then
orgn.noteOn(id, hz, vel)

if add then orgn.noteOn(id, hz, vel)
elseif rem then orgn.noteOff(id) end
-- Grab the chosen nb voice's player off your param
local player1 = params:lookup_param("nb_voice1"):get_player()
local player2 = params:lookup_param("nb_voice2"):get_player()
player1:note_on(midi_note, vel)
player2:note_on(midi_note, vel)
-- Play a note (id) at velocity (vel) for 0.2 beats (according to the norns clock)
-- player1:play_note(midi_note, vel, 2)
-- player2:play_note(midi_note, vel, 2)

elseif rem then
orgn.noteOff(id)

-- Grab the chosen nb voice's player off your param
local player1 = params:lookup_param("nb_voice1"):get_player()
local player2 = params:lookup_param("nb_voice2"):get_player()
player1:note_off(midi_note)
player2:note_off(midi_note)
end
end
}
end)
Expand Down Expand Up @@ -146,39 +166,30 @@ function App.grid(args)
_ratio.b()
_ratio.a()
end

_oct.up()
_oct.down()
if wide then
_voicing()
_scale()
end
_mode()
_ramp()

local gx, gy, gz = nest.grid.input_args()

--these if statments are a hack to fix superfluous pattern watch events when interacting with the PatternRecorder components
if (nest.render.mode == 'redraw') or (gx < 16) then
_oct.up()
_oct.down()
if wide then
_voicing()
_scale()
end

if demo.playing() then
_demo()
_patrec{
x = wide and 16 or { 1, 2 }, y = wide and { 4, 7 + lr } or 2,
pattern = pattern, varibright = varibright,
}

if demo.playing() then
_demo()
else
if scale_focus then
_scale_degrees{ preset = params:get('scale_preset') }
_tonic{ preset = params:get('scale_preset') }
else
if scale_focus then
_scale_degrees{ preset = params:get('scale_preset') }
_tonic{ preset = params:get('scale_preset') }
else
_keymap()
end
_keymap()
end
end
if (nest.render.mode == 'redraw') or (gx >= 16) then
_patrec{
x = wide and 16 or { 1, 2 }, y = wide and { 4, 7 + lr } or 2,
pattern = pattern, varibright = varibright,
}
end

end
end

Expand Down
17 changes: 16 additions & 1 deletion orgn.lua
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ Key, Enc = include 'lib/nest/norns'
Text = include 'lib/nest/text'
Grid = include 'lib/nest/grid'


multipattern = include 'lib/nest/util/pattern-tools/multipattern'
of = include 'lib/nest/util/of'
to = include 'lib/nest/util/to'
Expand All @@ -59,6 +60,9 @@ Orgn = include 'orgn/lib/ui' --nest v2 UI components (norns scr
map = include 'orgn/lib/params' --create script params
m = include 'orgn/lib/midi' --midi keyboard input

--nb lib or orgn
nb = include 'orgn/lib/nb/lib/nb'

engine.name = "Orgn"

--set up global patterns
Expand Down Expand Up @@ -94,12 +98,23 @@ nest.connect_screen(_app.norns, 24)
--init/cleanup

function init()
print("orgn init")
orgn.init()
params:read()
params:set('demo start/stop', 0)

nb:init()
params:add_separator("externals")
-- nb:add_param("voice_t"..t, "OUTPUT")
nb:add_param("nb_voice1", "OUTPUT1")
nb:add_param("nb_voice2", "OUTPUT2")
params:add_separator("VOICE CONTROLS")
nb:add_player_params()


params:bang()
end

end
function cleanup()
params:write()
end