Skip to content

Commit

Permalink
launch/exolang initiatialization can take a webAudioContext argument
Browse files Browse the repository at this point in the history
  • Loading branch information
dktr0 committed Nov 5, 2024
1 parent 8fc3bcb commit c27d40f
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 33 deletions.
9 changes: 5 additions & 4 deletions exolang.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import * as P from './output/Main/index.js';

export function exoLang() {
return new Punctual();
export function exoLang(args) {
return new Punctual(args);
}

export function Punctual() {
this.punctual = P.launch();
export function Punctual(args) {
if (args==null) args = {};
this.punctual = P.launch(args)();
}

Punctual.prototype.define = function(args) {
Expand Down
48 changes: 24 additions & 24 deletions punctual.js

Large diffs are not rendered by default.

10 changes: 6 additions & 4 deletions src/Main.purs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import Effect.Class.Console (log)
import Effect.Class (liftEffect)
import Control.Monad.Error.Class (throwError)
import Effect.Exception (error)
import Data.Nullable (Nullable,toMaybe)

import Signal (SignalInfo,emptySignalInfo)
import Program (Program,emptyProgram,programHasVisualOutput,programHasAudioOutput,programInfo)
Expand All @@ -27,7 +28,7 @@ import SharedResources (SharedResources)
import SharedResources as SharedResources
import WebGL (WebGL, newWebGL, updateWebGL, deleteWebGL, drawWebGL)
import AudioZone (AudioZone,newAudioZone,redefineAudioZone,deleteAudioZone)
import WebAudio (WebAudioNode)
import WebAudio (WebAudioNode,WebAudioContext)

type Punctual = {
sharedResources :: SharedResources,
Expand All @@ -41,9 +42,10 @@ type Punctual = {
}


launch :: Effect Punctual
launch = do
sharedResources <- SharedResources.newSharedResources Nothing
launch :: { webAudioContext :: Nullable WebAudioContext } -> Effect Punctual
launch args = do
let mWebAudioContext = toMaybe args.webAudioContext
sharedResources <- SharedResources.newSharedResources mWebAudioContext
programs <- new empty
previousPrograms <- new empty
programInfos <- new empty
Expand Down
1 change: 0 additions & 1 deletion src/SharedResources.purs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ type SharedResources = {
audioWorkletCount :: Ref Int,
brightness :: Ref Number
}


newSharedResources :: Maybe WebAudioContext -> Effect SharedResources
newSharedResources mWebAudioContext = do
Expand Down

0 comments on commit c27d40f

Please sign in to comment.