-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Persisting audio graph definitions using functions #267
Comments
Apologies if I broke anything with this change, I didn't actually think anyone would have this usecase. Some graphs probably don't translate well to storing server-side - especially when they make use of timing. Would be interested to hear more about how you're using the library? I think that it would be very straightforward to create a little DSL to get around this issue. For instance if you want to store this graph on the server: virtualAudioGraph.update({
0: gain('output', { gain: 0.5 }),
1: oscillator(0),
}) You could store a data structure like: const audioGraph = {
0: ['gain', 'output', { gain: 0.5 }],
1: ['oscillator', 0]
} Then use a function that compiles that to a format that virtual-audio-graph understands: import * as nodes from 'virtual-audio-graph'
const compileAudioGraph = (audioGraph) => Object.fromEntries(
Object.entries(audioGraph)
.map(([key, [nodeName, ...nodeArgs]]) => [key, nodes[nodeName](...nodeArgs)])
)
virtualAudioGraph.update(compileAudioGraph(audioGraph)) Haven't actually run that code, but something like that should work. Does that make sense? |
Yes, that makes sense. Thanks for the example compilation function - and no worries about the breaking change, that was clearly documented in the release notes, just wondering if I should stay on < v0.20.0, while it would be good to sync with the latest bugfixes and it's interesting to try out the support for AudioWorklets. That mapping function could be the way to go. I'm using this library for the synth.is pet project, where it has been super helpful - Thanks! - intro video and another. Haven't been working on this in the past months but hope to find time for another iteration soon, where I would need to revisit the usage of virtual-audio-graph. PauchDB is used for local persistence (initial plan was to use the sync features it offers but that was abandoned and now it's just persisting to IndexedDB) but when audio signal patches are published at synth.is, they are saved in MinIO buckets as plain text files. |
Cool project! |
Hey @benji6, and happy holidays 🎄 I'm still using that v0.19.9 tag and just made one modification which you might be interested in for the current version of this project:
|
Hi @bthj, thanks for the holiday wishes, hope you had a good time! Apologies for the delay in my response. OscillatorNodes don't support offset time and it is not listed as supported in the docs. With AudioBufferSourceNodes the offset specifies the offset that the audio clip starts at. When I try to pass a second parameter to an OscillatorNode start method I'm observing no errors and the node works the same way as if I had passed a single parameter to the start method. I'm not sure how your proposed change will affect the behavior of the library in that case? |
Hi @benji6 - the change I made there to the |
…d to keep stricly inline with the specification and to avoid bugs in non-browser Web Audio implementations like node-web-audio-api Fixes #267
Ah I see! I had not tested it with node-web-audio-api - seems like the implementation is different than in the browser. This issue definitely existed in the latest release. I have just pushed a fix f898b09. Latest release should work https://github.com/benji6/virtual-audio-graph/releases/tag/v1.1.9. Thanks for flagging this :) |
🎉 This issue has been resolved in version 1.1.9 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Hi
Using versions before v0.20.0, where audio graphs are defined as arrays, it's easy to save the definitions, in e.g. a document database. But after the change to using functions for the audio graph definitions, I'm unsure how to go about persisting them:
Any ideas on how to achieve that?
The text was updated successfully, but these errors were encountered: