Skip to content

Commit

Permalink
Adds constant0Hack
Browse files Browse the repository at this point in the history
  • Loading branch information
Mike Solomon committed Oct 27, 2021
1 parent 5e221af commit 3020018
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 1 deletion.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.5.7] - 2021-10-27

### Added

- adds a hack that spews 0s to a context.

## [0.5.6] - 2021-10-27

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "purescript-wags",
"version": "0.5.5",
"version": "0.5.7",
"description": "Web Audio Graphs as a Stream",
"scripts": {
"build": "spago build",
Expand Down
12 changes: 12 additions & 0 deletions src/WAGS/Interpret.js
Original file line number Diff line number Diff line change
Expand Up @@ -1803,3 +1803,15 @@ exports.bufferDuration = function (buffer) {
exports.bufferNumberOfChannels = function (buffer) {
return buffer.numberOfChannels;
};
exports.constant0Hack = function (context) {
return function() {
var constant = context.createConstantSource();
constant.offset.value = 0.0;
constant.connect(context.destination);
constant.start();
return function() {
constant.stop();
constant.disconnect(context.destination);
}
}
}
4 changes: 4 additions & 0 deletions src/WAGS/Interpret.purs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ module WAGS.Interpret
, audioBuffer
, audioWorkletAddModule
, close
, constant0Hack
, connectXToY
, context
, contextState
Expand Down Expand Up @@ -217,6 +218,9 @@ foreign import makeFloatArray :: Array Number -> Effect WebAPI.BrowserFloatArray
-- | Make a new audio context.
foreign import context :: Effect WebAPI.AudioContext

-- | Send 0s from a context immediately. This is useful on iOS so that the context doesn't switch to a suspended state.
foreign import constant0Hack :: WebAPI.AudioContext -> Effect (Effect Unit)

-- | Get the state of the context
foreign import contextState :: WebAPI.AudioContext -> Effect String

Expand Down

0 comments on commit 3020018

Please sign in to comment.