
Security News
Deno 2.4 Brings Back deno bundle, Improves Dependency Management and Observability
Deno 2.4 brings back bundling, improves dependency updates and telemetry, and makes the runtime more practical for real-world JavaScript projects.
A browser-based audio programming language for music composition and audio synthesis.
Codebeat is a browser-based audio programming language for music composition and audio synthesis. This is an example application using the codebeat module.
Install:
npm install codebeat
Import and instantiate with voice config:
import Codebeat from 'codebeat'
const melody = new Codebeat({
tempo: 128, //default is 60
instrument: 'square', //default is 'sine'
timeSig: '3/4', //default is '4/4'
loop: true //default is false
})
Write and play:
melody.update({notes: `
t d4, t d_4,
t d4, q a#5,
q b5, q rest
`})
melody.play()
Note: Up to six audio contexts (voices) can be active on the window object. Each instance of Codebeat creates a new context.
A note's duration is the amount of time it is played relative to the tempo, known as a subdivision. Common subdivisions are abbreviated as follows:
Note: 3 triplets = 2 eighths
A note's name is mapped to its frequency in hertz. D in the 5th octave is written as d5
. Similarly, G-flat in the 3rd octave is g_3
, and C-sharp in the 6th octave is c#6
. A note may be between a0
and g#7
, inclusive.
h d5, q g_3, q c#6
[duration][space][note][comma]
Note: Any amount of tabs, newlines, or whitespace can appear after the comma, but one space must appear between the duration and pitch.
To simplify the writing process, groups of notes may be assigned to variable names. Notice the use of colons and semicolons in this example:
motif: h d5, q g_3, q c#6;
t d4, motif,
t a4, motif
Repeated notes may be multiplied by an integer value.
h c4 * 8, t b_3 * 3
Use the +
operator to play notes simultaneously. A chord is constituted of its pitches played for a specified duration.
chord: h d3 + a3 + g3;
h d3, chord,
h a3, chord
A note may be gradually altered over time until it reaches a new pitch. This is achieved with the -
operator.
slide: h e2 - e c3;
e f3, slide,
h b3, slide
To chain slides, use the z
duration for the destination note:
h e2 - z c3, h c3 - z f4, e f4 - z d3
This ensures that the entire duration of the slide is dictated by the duration of the source note.
Dynamics like gain, reverb, detuning, instrument, and distortion can be easily altered in a composition using the '@' tag.
@reverb 2/1.1/0.7,
@gain 75,
@instrument square,
h g3, w a5,
@instrument sine,
h g3, w a4
In the above example, the instrument is set to square and later changed to sine. Reverb and gain are set for the entire piece.
@reverb accepts 3 optional parameters delimited with '/': channel #, reverb length as a function of the sample rate, and decay rate.
@gain accepts 1 parameter: the amount of gain from 0 (mute) to 100 (maximum volume).
@detune accepts 1 parameter: the value in cents to detune a frequency.
@instrument accepts 1 parameter: the instrument name.
FAQs
A browser-based audio programming language for music composition and audio synthesis.
The npm package codebeat receives a total of 3 weekly downloads. As such, codebeat popularity was classified as not popular.
We found that codebeat demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.4 brings back bundling, improves dependency updates and telemetry, and makes the runtime more practical for real-world JavaScript projects.
Security News
CVEForecast.org uses machine learning to project a record-breaking surge in vulnerability disclosures in 2025.
Security News
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.