Skip to content

Commit a18d5a0

Browse files
committed
Readied README, added Seconds type to AudioBufferSourceNode
1 parent db33cd5 commit a18d5a0

File tree

2 files changed

+16
-48
lines changed

2 files changed

+16
-48
lines changed

README.md

Lines changed: 7 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,24 @@
11
# purescript-webaudio
22

3-
## About
4-
53
This is an experimental library for dealing with the HTML5 [Web Audio
64
API](https://webaudio.github.io/web-audio-api/)
75

8-
Module documentation is available [here](API.md).
9-
6+
## Installation
7+
bower install purescript-webaudio
8+
9+
## Examples
1010

11-
To build the examples to run in your browser, perform the following scripts in order:
11+
To build the examples perform the following scripts in order:
1212
1. `npm run build:example:xx` where xx is the example (siren, gain, decode, decodeAsync)
1313

1414
To run the examples in your browser, perform the following scripts in order:
1515
1. `npm run exec:example:xx` where xx is the example (siren, gain, decode, decodeAsync)
1616

17+
## Tests
18+
1719
To build the test suite
1820
1. `npm run build:test:props`
1921

2022
To run the test suite
2123
1. `npm run exec:test:props` and inspect the output log
2224

23-
24-
## Breaking Changes
25-
* Updated to work with `purs 0.11.x`
26-
* Renamed the `WebAudio` effect to `AUDIO` to conform with best practices
27-
* Renamed the `AudioNode` class as `RawAudioNode`
28-
* `AudioNode` is now a sum type over all the raw nodes.
29-
* Renamed `wau` to `audio`
30-
* Moved several fns from `AudioContext.purs` to `BaseAudiocontext` to match web audio spec
31-
* Created a `Connectable` class encompassing `connect`, `disconnect` & `connectParam` with AudioNode as an instance. This lives in `Types.purs`
32-
33-
## Improvements
34-
* Moved test/Test0X to `examples/` and renamed appropriately
35-
* Added `AudioParam.setTargetAtTime`
36-
* Updated `API.md` to reflect `decodeAudioData` error handling change
37-
* New type synomymns `Value` and `Seconds` for `AudioParam` methods
38-
* Eliminated `gulp`, putting new build test scripts in `package.json`
39-
* Added `decodeAudioDataAsync` to `BaseAudioContext`. This runs in Aff not Eff but has the advantage that audio buffers can be returned directly. This, of course, introduces a dependency on Aff 4.0.0 and requires users to lift the original Eff functions into Aff if they wish to use it. I hope that this overhead should not be too restrictive given that a natural way to load sound resources is via Aff anyway.
40-
* Added `decodeAsync` to illustrate basic usage. devDependencies now include `Affjax`.
41-
* Added `test/props` to test some simple properties of the new Node types.
42-
* Added `BiquadFilterNode`.
43-
* Added `detune` property to `Oscillator`.
44-
* Added `DelayNode`.
45-
* Added `disconnect` to Types.
46-
* Experimented with shorthand setters for `AudioParam` properties on some nodes.
47-
* Added `AnalyserNode` plus buffer creation functions in Utils. This introduces a dependency on `Data.ArrayBuffer`.
48-
* Added `StereoPannerNode`.
49-
* Added `DynamicsCompressorNode`
50-
* Added `ConvolverNode`
51-
52-
## adkelley ToDo:
53-
* Add further error handling options for `decodeAudioData` besides writing to console
54-
* Support for further nodes (e.g., ChannelSplitterNode), and interfaces
55-
56-
## newlandsvalley ToDo:
57-
* Document the changes from merging my fork

src/Audio/WebAudio/AudioBufferSourceNode.purs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@ module Audio.WebAudio.AudioBufferSourceNode
77
-- | See https://developer.mozilla.org/en-US/docs/Web/API/AudioBufferSourceNode.
88

99
import Prelude
10-
import Control.Monad.Eff (Eff)
11-
import Audio.WebAudio.Types (AudioBuffer, AudioBufferSourceNode, AUDIO)
10+
11+
import Audio.WebAudio.Types (AUDIO, AudioBuffer, AudioBufferSourceNode, Seconds)
1212
import Audio.WebAudio.Utils (unsafeGetProp, unsafeSetProp)
13+
import Control.Monad.Eff (Eff)
1314

1415
-- | Prime the node with its AudioBuffer.
1516
foreign import setBuffer
@@ -19,13 +20,13 @@ foreign import setBuffer
1920

2021
-- | Start playing the AudioBuffer.
2122
foreign import startBufferSource
22-
:: eff. Number
23+
:: eff. Seconds
2324
-> AudioBufferSourceNode
2425
-> (Eff (audio :: AUDIO | eff) Unit)
2526

2627
-- | Stop playing the AudioBuffer.
2728
foreign import stopBufferSource
28-
:: eff. Number
29+
:: eff. Seconds
2930
-> AudioBufferSourceNode
3031
-> (Eff (audio :: AUDIO | eff) Unit)
3132

@@ -39,16 +40,16 @@ setLoop l n = unsafeSetProp "loop" n l
3940

4041
-- | The time, in seconds, at which playback of the AudioBuffer must begin when
4142
-- | loop is true (default 0).
42-
loopStart :: eff. AudioBufferSourceNode -> (Eff (audio :: AUDIO | eff) Number)
43+
loopStart :: eff. AudioBufferSourceNode -> (Eff (audio :: AUDIO | eff) Seconds)
4344
loopStart = unsafeGetProp "loopStart"
4445

45-
setLoopStart :: eff. Number -> AudioBufferSourceNode -> (Eff (audio :: AUDIO | eff) Unit)
46+
setLoopStart :: eff. Seconds -> AudioBufferSourceNode -> (Eff (audio :: AUDIO | eff) Unit)
4647
setLoopStart l n = unsafeSetProp "loopStart" n l
4748

4849
-- | The time, in seconds, at which playback of the AudioBuffer must end when
4950
-- | loop is true (default 0).
50-
loopEnd :: eff. AudioBufferSourceNode -> (Eff (audio :: AUDIO | eff) Number)
51+
loopEnd :: eff. AudioBufferSourceNode -> (Eff (audio :: AUDIO | eff) Seconds)
5152
loopEnd = unsafeGetProp "loopEnd"
5253

53-
setLoopEnd :: eff. Number -> AudioBufferSourceNode -> (Eff (audio :: AUDIO | eff) Unit)
54+
setLoopEnd :: eff. Seconds -> AudioBufferSourceNode -> (Eff (audio :: AUDIO | eff) Unit)
5455
setLoopEnd l n = unsafeSetProp "loopEnd" n l

0 commit comments

Comments
 (0)