Comments (7)
This is the sort of challenge I'm up for.
from morse-decoder.
I'd be more than happy to accept your PR, @chris--jones.
from morse-decoder.
@ozdemirburak - I'm really close... I have a "working" wave export, branch is here: https://github.com/chris--jones/morsify/tree/wave-export
The complexity of wave conversion was taken largely from https://github.com/mattdiamond/Recorderjs/blob/master/src/recorder.js so a lot of credit to @mattdiamond
I'm not satisfied yet though, because:
- It uses the deprecated ScriptProcessorNode: https://developer.mozilla.org/en-US/docs/Web/API/ScriptProcessorNode
- It actually plays the audio to pipe it to the relevant node meaning that the export takes at least as long as the audio clip; this also has the side effect of interfering with the play functionality as I'm disconnecting from audio output and reconnecting when I'm done (attempting play in the middle of export may also interrupt the export).
I'm going to see if I can get this working via an OfflineAudioContext, but this will mean duplicating the audio nodes as you cannot connect them across contexts. This may not be a big deal, but if resource usage increases it might be better to expose the export interface as a separate construct so that the resources can be instantiated as required.
Finally I'd like to ask about the API itself - presently I'm returning the Blob object containing the wave data as this is the most flexible, however it will most likely be used via a call to URL.createObjectURL(blob);
to either assign it to an audio player or start a download - so it might make sense to return this object url or even offer a convenience method to start a download.
from morse-decoder.
@chris--jones It is definitely great progress for the initial commit.
I think when someone calls the export method, it should start a download by default. But, maybe there can be an optional parameter for returning the blob object.
I'll also have a detailed look tomorrow. Thanks again.
from morse-decoder.
I have it working with OfflineAudioContext now and it works as I had hoped - exporting the file very quickly 👍
I will need to refactor a bit to maintain both contexts, and unfortunately OfflineAudioContext requires me to iterate over the morse to get the audio length to initialise the offline audio context, only for it to then have to iterate over the morse again to set the gain levels which I can't do until I get the gain from the context 😠 ...oh well.
If it sounds ok to you, I'll submit my PR once it's working via offline audio context and defer working on the migration to the newer AudioWorkletNode (https://developer.mozilla.org/en-US/docs/Web/API/AudioWorkletNode) as a separate issue as it looks like it may require externalising the processing audio node script so that it can be run as a worker thread which may mean multiple scripts in the solution (I'm guessing you prefer the simplicity of a simple file).
from morse-decoder.
Sure, sounds great. About the AudioWorkletNode, I am not familiar with it, but that definitely looks like an ideal solution.
from morse-decoder.
@ozdemirburak - I managed to solve it without using the deprecated script node as the offline audio context provides a buffer in the complete event. This site was a great help: http://joesul.li/van/tale-of-no-clocks/
I've added more details in the PR #17
from morse-decoder.
Related Issues (16)
- Thai Alphabet HOT 3
- End of audio detection HOT 1
- Ukrainian leter "ґ" is missing HOT 2
- Error HOT 1
- oscillator of null HOT 3
- Sending request HTTP request to https://morsedecoder.com/ HOT 2
- Migrate Code to TypeScript HOT 4
- Split Typescript logic into several files HOT 3
- Failed to execute 'stop' on 'AudioScheduledSourceNode': cannot call stop without calling start first. HOT 5
- Hatalı tanımlama HOT 2
- Modify Options - Add WPM and Volume Parameters HOT 4
- Proposed API updates to audio functions HOT 12
- Transpile ES5 to ES6 HOT 2
- The text is mixed up in places for buttons "dot" and "dash" on https://morsedecoder.com/learn-morse-code/ HOT 1
- Can't Play the Audio More Than Once in Safari Mobile (Web Audio API) HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from morse-decoder.