-
Notifications
You must be signed in to change notification settings - Fork 34
Audio
In Beact, there are two ways generating sounds: keyboard and sequencer.
We use keymaster to listen on keyboard event. When key event occurs, we play the matching audio sample from Multiplayer by Tone.js.
Start or stop the sequencer by the current boolean state playing.
Pass +10 or -10 to the Transport.bpm to change the sequencer playing speed.
Point to the next or previous element in the array named drumUrls, which contains different sample sets, and loadSamples() to change sequencer's sample set.
By 2D array, we set 16 columns with audio samples to loop through. Each column contains 8 samples, marked as 1 or 0 for play or not to play.
When the sequencer starts, it plays from the first column's first element to the last. Then the second column. Once it plays through the last column, it starts from first column again.
Samples from the same column sound like playing at the same time due to short processing time, while fixed notation spaning between columns makes the sample playing a beat.
We Post the 2D array of current sequencer schema and the inputed pattern name to database. We get the API and setState to render the pattern list.
Whenever the list item is clicked, the schema of sequencer would be changed as the pattern in state.
We could continually push the 2D array of sequencer schema into the array of state drumNoteChain. As the sequencer reaches an end of a schema, it plays the schema of the second array element, and so on. Once it plays through the last array element, it starts again from the first.
Push the keys which are played during recording with their invoking times (Transport.seconds) into the array named record, then save it in database.
Store each column as sequencer plays through in 2D array recordMatrix. Once stored columns filled recordMatrix's 16 elements, it would be push into the array named recordFill, and recordMatrix would be cleared and continue to store played columns. They would be saved in database.
Render the record list by getting the API and setState.
When the record list item is clicked, the sequencer begins to play. The schema of sequencer is ever-changing based on record.content, and the keyRecords would be played just as they are recorded according to their invoking time.
Beact by Vibert, Joey, Scya, 2017