Comments (4)
No, the data
event is emitted a number of times as data becomes available from the decoding pipeline. There isn't currently a very good way of decoding the whole file without writing a small function yourself. I plan to add this to the Asset
class soonish.
First of all, make sure you're using the namespace
branch from Github. It's much more up to date, and there's really no reason I haven't merged it in yet. Here's a small function that can decode the whole file into a BufferList
that you can merge at the end into a single buffer if you really need to:
var list = new AV.BufferList;
asset.on('data', function(chunk) {
list.append(new AV.Buffer(new Uint8Array(chunk.buffer)));
});
asset.on('end', function() {
// merge bufferlist into a single buffer if you need to...
var buf = new Uint8Array(list.availableBytes);
var cur = list.first;
var offset = 0;
while (cur) {
buf.set(cur.data, offset);
offset += cur.length;
cur = cur.next;
}
// buf now contains all of the buffers. do what you want with it here...
});
(function decode() {
while (asset.decoder.decode());
asset.once('data', decode);
})();
The code above is totally untested so something like it will probably work. :)
Like I said, this should obviously be a lot better, so I'm leaving the issue open to remind me to make it so. Good luck!
from aurora.js.
Hi Ayke, I'm curious about your ABX testing app, since I'm currently
working on something similar (github.com/mmontag/audio-listening-test).
Is it something you are able to share?
Matt
On Fri, Feb 22, 2013 at 3:10 PM, Ayke van Laethem
[email protected]:
This is sort-of a question (possibly a bug).
I'm developing a small web application to do ABX testing in the browser.
It works with the Web Audio API as that is going to be the future (the
Firefox api is deprecated). It needs to decode the entire audio file in
memory, as it is currently implemented. I wanted to add FLAC support (as
FLAC isn't very well supported in browsers, AFAIK only Chrome OS has
support for the format).
The test.html (in flac.js) worked. I added a 'data' event handler to the
asset (player.asset). When playing the audio file (via player.play()), the
data callback fired for every bit of data (which I do not want, I want the
entire arraybuffer), but when calling player.asset.start(), two chunks of
data were given to the data callback, but nothing more happened.Is it actually possible to decode the whole file in one arraybuffer
(possibly in a Web Worker)? The documentation (
https://github.com/ofmlabs/aurora.js/wiki/Asset-Class-Reference#wiki-data-event)
seems to suggest the 'data' callback is called when the whole file is
decoded.—
Reply to this email directly or view it on GitHubhttps://github.com/ofmlabs/aurora.js/issues/20.
from aurora.js.
The testing app is here: http://webabx.nfshost.com/. It is implemented in pure JavaScript (no server side processing whatsoever, I don't even host any audio files because they're quite bandwidth and storage heave).
It might be possible to make some sort of API that can redirect, or something via an iframe or something. If you're interested, I can mail you (as this isn't really the place to talk about it). And, I haven't said it there, but I plan to license the code under the BSD license, so maybe you can just copy the code once it's licensed (with proper attribution, of course). It still has some bugs, though.
I am thinking of refactoring the whole thing to make it modular and to not load the whole file in memory (in PCM data, which is quite a lot). It uses at least a few hundreds MBs on my computer for a moderate song (actually, two songs, as two are played at the same time), so that's not very optimal. The reason I use this system is because I can start them at exactly the same time easily.
I think instead of loading the whole buffer in memory I'll refactor it in such a way that partial buffers are used (making the whole thing a lot more efficient). FLAC support isn't high priority for me (WAV already works), but would be nice to have so maybe once the refactoring is done I'll look into it again.
I asked this in the first place to ask a question (as I couldn't find another place). As that question is answered, maybe it's better to close this bug?
from aurora.js.
No, I'll leave it open as a reminder to myself. I still want to add this feature. Thanks!
from aurora.js.
Related Issues (20)
- How do I decode to raw, resample to 44,1khz and split stereo into dual mono buffers?
- "Something is wrong in HTTPSource.loop" while using AV.Asset.fromURL(remoteUrl)
- [Solved]switch backend from Speaker to PortAudio(naudiodon)
- Aurora not playing certain flac files with no error
- Live decoding on Android
- Node example HOT 1
- No default jsDelivr CDN file set
- Problems with 24-bit WAV files
- Questions about memory manage.
- Is decoding a specific part of a gargantuan file supported efficiently? HOT 3
- HTTP requests still sending to server even if HTTP error is returned
- Unit tests fail on master branch
- Chrome browser change for same site cookies
- gyp build fail HOT 1
- build for browser
- m4a demuxer fails when processing a file with co64 atom
- Window Not Defined
- decode fail
- How to install additional codecs? HOT 1
- Uncaught SyntaxError: Unexpected identifier 'key'
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 aurora.js.