Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clock.lua module added #393

Merged
merged 22 commits into from
Apr 22, 2021
Merged

clock.lua module added #393

merged 22 commits into from
Apr 22, 2021

Conversation

trentgill
Copy link
Collaborator

Fixes #339

This is a basic implementation of the the norns clock module. It's based on the initial implementation by @artfwo rather than the recently updated one. I will lilkely revisit this before 3.0 to refine some things. Especially using the CV input as the clock source needs some refinement (it seems quite drifty, and perhaps there are double-triggers).

Usage is similar to norns, but with some key differences & helper functions that are specific to the crow workflow:

--- All of the basics are identical to norns:
myclock = clock.run(function()
  while true do
    print'hi!'
    clock.sync(1/4) -- synchronise to the next 1/4 of a beat
  end
end)
clock.sleep(n) -- sleep for n seconds
clock.suspend() -- suspend until manual restart
clock.resume(myclock) -- resume a suspended coroutine
clock.get_beats() -- beats elapsed since starting
clock.get_beat_sec() -- convert beats to seconds at current tempo

--- Differences on crow are mostly about syntax relating to tempo & clock source
-- internal timebase (default)
clock.start() -- selects the internal timebase & starts the clock (this is effectively run at init())
clock.stop() -- selects the internal timebase & stops the clock [This doesn't actually stop though?]

-- tempo just works as a variable
clock.tempo = 160 -- set internal tempo to 160bpm (ignored if using external source)
print( clock.tempo ) -- print the current tempo (uses external source if active)

--- CV inputs as timebase
-- when choosing clock mode, internal timebase is disabled
input[1].mode('clock',1/4) -- set timebase to use input jack 1, where each trigger == clock.sync(1/4)

--- output helpers: create a tempo clock with one line
output[1]:clock(1/4) -- set output 1 to pulse every clock.sync(1/4), ie 4 times per beat
-- by default output.clock sets the ASL action to pulse(), but you can reassign it
output[1].action = ar() -- now the clock will trigger an envelope instead of a pulse

@tehn
Copy link
Member

tehn commented Apr 22, 2021

this is super great! only issue:

clock.suspend() -- suspend until manual restart
clock.resume(myclock) -- resume a suspended coroutine

both of these will be deprecated. @artfwo and @ngwese agreed (in vid meeting recently) that they were not quite what was required for a particular use case--- and then there weren't really any sensible remaining use cases for these.

@trentgill trentgill merged commit 10c8ebc into THREE Apr 22, 2021
trentgill added a commit that referenced this pull request Jun 30, 2021
* can now update output[n].scale(_) with .scale = {note list}, so it can be dynamically set like a regular table (#373)

* fix bug where aliasing an ii address before use could stack overflow (#374)

* querying output voltage now returns the shaped & scaled voltage (real voltage at jack)

* add just intonation helpers: justvolts(), just12()
* support input scales: input[n].mode( 'scale', {...}, 'ji')
* support output scales: output[n].scale({...}, 'ji')

* Python based bootloader support and dfureset (#377)
* `make pydfu` to use python3 dfu bootloader
* `make dfureset` jumps to bootloader from make
* `make zip` now builds dfu file as well as binary
* add instructions for using pydfu instead of dfu-util

* Frequency detect mode for input[1] (#382)
* `input[1].mode('freq', interval)` reports frequency of a signal connected to input 1 (no support for input 2)
* `hztovolts(hz, <ref>)` helper fn converts an input hz equivalent voltage (uses default reference to match Just-Friends & W/Syn)

* print an error to usb host if event queue overflows (#391)

* clock.lua module added (#393)

* New calibrate.lua & underlying engine (#397)
Breaking:
* `cal` lua module refactored with new API
* calibration no longer auto-runs if no vals saved (ie new factory modules)
* `util/recalibrate.lua` demonstrates usage, and can be used for factory calibration (or at home)

* double userscript storage size to 16kB (#396)

* add jacktest.lua

* strip debug info from crow lua libs for dramatic ram reduction (#395)

* Sequins.lua library (#387)
* add sequins library

* ASL2 (#399) ASL2 library. Runtime operates in C for greatly optimized performance & sample accuracy

* introduce Caw_printf

* Public.lua library for sharing parameters (#394)
* after calling init() crow sends '^^ready()'
* add 'public.view' for enabling live monitoring of in & out voltages

* Oscillate asllib fn (#407)
* add 'oscillate' asllib fn

* add note about not using `note` in asllib. kept only to avoid the breaking change

* add quote library & remove quotes global (#412)

* support ii getters from teletype (#403)

Co-authored-by: brian crabtree <tehn@monome.org>
@trentgill trentgill deleted the clocks branch July 3, 2021 17:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants