{"id":17025878,"url":"https://github.com/munshkr/tilt","last_synced_at":"2025-04-14T17:11:16.771Z","repository":{"id":44818426,"uuid":"162860681","full_name":"munshkr/tilt","owner":"munshkr","description":"Live coding bytebeat-style language for the web","archived":false,"fork":false,"pushed_at":"2023-01-06T01:54:10.000Z","size":3965,"stargazers_count":34,"open_issues_count":5,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-28T05:51:03.390Z","etag":null,"topics":["bytebeat","live-coding","livecoding","waveshaper","webaudio"],"latest_commit_sha":null,"homepage":"https://munshkr.github.io/tilt/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/munshkr.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":null,"patreon":null,"open_collective":null,"ko_fi":"munshkr","tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"lfx_crowdfunding":null,"custom":null}},"created_at":"2018-12-23T03:57:25.000Z","updated_at":"2024-09-08T21:46:23.000Z","dependencies_parsed_at":"2023-02-05T02:00:42.471Z","dependency_job_id":null,"html_url":"https://github.com/munshkr/tilt","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/munshkr%2Ftilt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/munshkr%2Ftilt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/munshkr%2Ftilt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/munshkr%2Ftilt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/munshkr","download_url":"https://codeload.github.com/munshkr/tilt/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248923764,"owners_count":21183954,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bytebeat","live-coding","livecoding","waveshaper","webaudio"],"created_at":"2024-10-14T07:30:09.182Z","updated_at":"2025-04-14T17:11:16.739Z","avatar_url":"https://github.com/munshkr.png","language":"JavaScript","funding_links":["https://ko-fi.com/munshkr"],"categories":["JavaScript"],"sub_categories":[],"readme":"# Tilt\n\nBytebeat-inspired live coding thingie for waveshaping synthesis.\n\nRuns on modern browsers using the WebAudio API.\n\n## Tutorial\n\nCheck out the tutorial if you want to learn how to use Tilt while also learning a little bit about sound synthesis :-)\n\n* [English](tutorial.md)\n* [Español](tutorial.es.md)\n\n## Usage\n\nTo make some audio, define the value of the variable `o`. It must be a number\nbetween 0 and 1. For this, you can use the `t` parameter, which is an\nalways-increasing counter.\n\nFor example, to make a sine wave at 440hz:\n\n```javascript\no = sine(t);\n```\n\nEvaluate code by pressing the Play button, or \u003ckbd\u003eCtrl\u003c/kbd\u003e+\u003ckbd\u003eEnter\u003c/kbd\u003e\n(or \u003ckbd\u003eCommand\u003c/kbd\u003e+\u003ckbd\u003eEnter\u003c/kbd\u003e). You can stop sound by pressing the\nStop button, or \u003ckbd\u003eCtrl\u003c/kbd\u003e+\u003ckbd\u003e.\u003c/kbd\u003e.\n\nYou can make all sorts of simple (and more complex) waveforms:\n\n```javascript\n// saw wave\nlet q = 2 * pi;\no = (t % q) / q;\n```\n\n```javascript\n// square wave\nlet q = 2 * pi;\no = (t % q) / q \u003e 0.5;\n```\n\n```javascript\n// pulse wave with pulse-width modulation\nlet q = 2 * pi;\no = (t % q) / q \u003e seq(256, 64) / 64;\n```\n\n```javascript\n// triangle wave\nlet ramp = (t % q) / q;\no = ((ramp \u003e 0.5 ? ramp : 1 - ramp) - 0.5) * 2;\n```\n\nThese simple _waveforms_ are also already defined as functions. Read below.\n\nThere is also a parameter `K` which is static and represents the number of\nsamples in a _cycle_. It is used to make _rhythm_. See the function `seq` or\n`randInt`, as they use it internally.\n\nA more complex example, using some of the functions described below:\n\n```javascript\no = sine(t / (randInt(8, 32) + 1)) * env(8, 1) * 0.75;\no +=\n  sine((t * aseq(16, [2, 3, 2, 7, 8])) / 4 + sine((t / aseq(8, [1, 2])) * 1.0001)) *\n  invEnv(seq1(32, 8), seq1(4, 8) + 1) *\n  0.75;\n```\n\nRemember that `o` should be a number between 0 and 1. If you add multiple\nwaveforms, you should scale them down to mix them properly. For example,\ninstead of:\n\n```javascript\no = sine(t) + tri(t);\n```\n\nYou should do something like this:\n\n```javascript\no = sine(t) * 0.5 + tri(t) * 0.5;\n```\n\nWhy 0.5? Because both `sine(t)` and `tri(t)` output values from 0 to 1. If\nyou multiply them with 0.5 (or divide them by 2), they should range between 0\nand 0.5, which when both are added up, they end up ranging from 0 to 1.\n\n## Functions\n\nCode is written in JavaScript, but there are some useful constants and\nfunctions available.\n\n### Math\n\nMost of the functions from `Math` object in JavaScript are defined as globals,\nbut the following are the most useful:\n\n- `pi`: Pi constant.\n- `two_pi`: 2 times Pi\n- `abs(arg)`: Returns the absolute value of a number.\n- `sin(arg)`: Returns the sine of a number.\n- `tan(arg)`: Returns the tangent value of a number.\n- `tanh(arg)`: Returns the hyperbolic tangent value of a number.\n- `floor(arg)`: Returns the largest integer less than or equal to a given\n  number.\n- `ceil(arg)`: Returns the smallest integer greater than or equal to a given\n  number.\n- `pow(arg)`: Returns base to the exponent power.\n- `round(arg)`: Returns the value of a number rounded to the nearest integer.\n- `sqrt(arg)`: Returns the positive square root of a number.\n\nNote: `sin` returns a number from -1 to 1, there is also `sine` which\nreturns a number from 0 to 1, suitable as audio output.\n\n### Waveforms\n\nThese functions all return numbers from 0 to 1, so they can be used directly as\naudio output.\n\n- `sine(t)`: Sine waveform\n- `saw(t)`: Saw waveform\n- `pulse(t, width)`: Pulse waveform\n- `square(t)`: Square waveform (same as Pulse with width 0.5)\n- `tri(t)`: Triangle waveform\n\n### Sequences\n\n- `seq(subdiv, subdiv)`: Returns a number from 0 to `length - 1` in `subdiv`\n  subdivisions of a cycle (defined by `K`).\n- `seq1(subdiv, length)`: Same as `seq`, but number range from 1 to `length`.\n  subdivisions of a cycle (defined by `K`).\n- `aseq(subdiv, array)`: Returns values from `array` in `subdiv` subdivisions\n  of a cycle. Basically, sequences an array.\n\n### Envelopes\n\n- `env(subdiv, curve, smooth)`: Generates an exponential envelope that lasts\n  `subdiv` subdivisions of a cycle, with an exponent `curve`. The optional\n  `smooth` argument is a 0-1 number that splits the envelope into an increasing\n  linear ramp for a smoother attack (0=no smoothing, 1=linear ramp).\n- `invEnv(subdiv, curve, smooth)`: Same as `env` but generates an inverse\n  exponential envelope. The `smooth` argument controls a decreasing ramp at the\n  end of the envelope.\n\n### Random\n\n- `rand(subdiv, seed)`: Returns a random number between 0 and 1. The number is\n  held during `subdiv` subdivisions of a cycle. When using the same `seed` you\n  can generate the same sequence of random numbers.\n- `randInt(subdiv, max, seed)`: Same as `rand` but generates a integer numbers\n  from 0 to `max`.\n\n### Time\n\nThese functions generally replace the use of the `t` counter variable for musically-related concepts:\n\n- `f(frequency)`: Generates a counter at the specified frequency (e.g.\n  `sine(f(440)) == sine(t)`).\n- `m(midinote)`: Generates a counter at the specified MIDI note (e.g.\n  `sine(m(69)) == sine(t)`, because 69 is the A4, which is 440Hz).\n\n## License\n\nGPL 3+. Refer to [LICENSE.txt](LICENSE.txt)\n\nIcons:\n\n- Play by Eagle Eye from the Noun Project\n- Stop by vectoriconset10 from the Noun Project\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmunshkr%2Ftilt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmunshkr%2Ftilt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmunshkr%2Ftilt/lists"}