项目
在 GitHub 查看
unkleho/reactronica
关于
用于在浏览器中创作音乐的 React 音频组件
设计与媒体实测星标增长
- 24小时
- 0
- 7天
- 0
- 15天
- +1
- 1个月
- 正在收集历史
各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。
README.md
原文Reactronica
React audio components for making music in the browser.
React treats UI as a function of state. This library aims to treat music as a function of state, rendering sound instead of UI. Visual components live side by side with Reactronica, sharing the same state and elegantly kept in sync.
Uses ToneJS under the hood. Inspired by React Music.
Warning: Highly experimental. APIs will change.
Install
$ npm install --save reactronica
Note: Use React version >= 16.8 as Hooks are used internally.
Template
To get started quickly with Create React App and Reactronica, just run the command below:
$ npx create-react-app my-app --template reactronica
Documentation
Components
Demos
Usage
import React from 'react';
import { Song, Track, Instrument, Effect } from 'reactronica';
const Example = () => {
return (
// Top level component must be Song, with Tracks nested inside
<Song bpm={90} isPlaying={true}>
<Track
// Array of several types
steps={[
// Note in string format
'C3',
// Object with note name and duration
{ name: 'C3', duration: 0.5 },
{ name: 'D3', duration: 0.5 },
// Array of strings for chords
['C3', 'G3'],
null,
null,
// Array of objects for chords
[
{ name: 'C3', duration: 0.5 },
{ name: 'G3', duration: 0.5 },
],
null,
]}
volume={80}
pan={0}
// Callback for every tick
onStepPlay={(step, index) => {
console.log(step, index);
}}
>
<Instrument type="synth" />
{/* Add effects chain here */}
<Effect type="feedbackDelay" />
<Effect type="distortion" />
</Track>
<Track>
<Instrument
type="sampler"
samples={{
C3: 'path/to/kick.mp3',
D3: 'path/to/snare.mp3',
E3: 'path/to/hihat.mp3',
}}
// Add some notes here to play
notes={[{ name: 'C3' }]}
onLoad={(buffers) => {
// Runs when all samples are loaded
}}
/>
</Track>
</Song>
);
};
Thanks
- https://tonejs.github.io/
- https://github.com/FormidableLabs/react-music
- https://github.com/jaredpalmer/tsdx
- https://github.com/crabacus/the-open-source-drumkit for the drum sounds
License
MIT © unkleho
探索相关项目
加载中…