Questions tagged [arraybuffer]

ArrayBuffer is a Javascript data type used to represent a generic, fixed-length binary data buffer.

597 questions
3
votes
0 answers

Totally not getting something about ArrayBuffers and DataViews.

Here's what I'm trying to do (trying to convert the upper 3 bytes of a little endian number at a point in an ArrayBuffer into the number itself): var tmp = new DataView("\0" + array_buffer.slice(i+4, i+7), 0, 4).getUint32(0, true); This fails…
KarenRei
  • 589
  • 6
  • 13
3
votes
1 answer

JavaScript is not allocating needed size for ArrayBuffer

I tried to run this code to allocate a ArrayBuffer: var data = new ArrayBuffer(336000000); console.log(data.byteLength); // outputs 125829120 Does anyone know why the number if bytes is not allocated? Chrome don't give me any errors /…
3
votes
2 answers

Convert binary file to JavaScript string and then to Uint8Array

I'm trying to create a web application that can be used via a file:// URI. This means that I can't use AJAX to load binary files (without turning off security features in the browser, which I don't want to do as a matter of principle). The…
Jackson
  • 9,188
  • 6
  • 52
  • 77
3
votes
1 answer

Initialize Javascript ArrayBuffer with zeroes

Is there a method to set all indices in an ArrayBuffer to 0 that is optimized to be fast? I know I can do an iteration to do it manually but I was wondering if there is some built-in that does it fast as I want to do this once per animation frame.
Alex Bollbach
  • 4,370
  • 9
  • 32
  • 80
3
votes
0 answers

How to return ArrayBuffer to the client by Nodejs

I want to use Node.js to return arrayBuffer to the client, but I found some problems. my node server.js: res.write(new…
laoqiren
  • 3,457
  • 5
  • 19
  • 29
3
votes
2 answers

How do you download a PDF from an API in angular2 RC5?

This previous question had some good work arounds: Angular 2 download PDF from API and Display it in View but now that RC5 is out we can use arrayBuffer(). I can't seem to get anywhere with this. How do I go from this to a nice pdf blob: return…
Ruben Valas
  • 71
  • 1
  • 1
  • 5
3
votes
1 answer

Read Memory in SharedArrayBuffer

In an attempt to parallelize treatment on large TypedArrays, I tried to use the mozilla extension named SharedArrayBuffer. These objects allow concurrent workers (or main thread) to handle the same memory (which is not made unavailable to caller of…
Regis Portalez
  • 4,675
  • 1
  • 29
  • 41
3
votes
2 answers

Playing incoming ArrayBuffer audio binary data from binaryjs server simultaneously

Good day! I'm into video chat streaming this morning and I've bumped into a problem with the incoming ArrayBuffer which contains binary data of an audio. Here is the code I found for playing binary audio data (Uint8Array): function…
3
votes
0 answers

Convert file to ArrayBuffer in javascript

I'm trying to follow this example about media source extensions. I have a webm file at a given URL, and I want to append it to my video tag. My code is: Template.video.events({ 'click button': function () { var ms = new MediaSource(); …
Mascarpone
  • 2,516
  • 4
  • 25
  • 46
3
votes
0 answers

fetch array buffer random behavior

I want to fetch directly an arrayBuffer using the fetch api (https://fetch.spec.whatwg.org/). Once the data is returned, I want to use the array buffer. It appears that sometimes arrayBuffer() works and sometimes it doesn't. By doesn't work I mean…
Nicolas
  • 2,191
  • 3
  • 29
  • 49
3
votes
2 answers

PNG or JPG (not rgb) over websocket with ArrayBuffer without base64

Is there a way to render a PNG image to canvas without having to encode it to base64? Server sends a PNG in binary, client receives it in an ArrayBuffer and displays it on the canvas. Only way I could get this to work is by encoding the data to…
Evren Bingøl
  • 1,306
  • 1
  • 20
  • 32
3
votes
1 answer

When should I use "new" in scala?

When I use ArrayBuffer, I should use: val arr = new ArrayBuffer[Int] but when I use Map, I should use: val map = Map[Int, Int]()
user2848932
  • 776
  • 1
  • 14
  • 28
3
votes
1 answer

Swapping byte order with DataView and TypedArrays

Hi all I'm learning DataView and TypedArrays. I have an array of LONG's and USIGGNED_LONG's, I'll just paste the LONG one below. I've been trying to swap the array at bottom which is in ARGB to be RGBA. The first step I do is making it a Uint32Array…
Noitidart
  • 35,443
  • 37
  • 154
  • 323
3
votes
1 answer

Three.js: How to create new 'morphing' geometry if I have all necessary buffers?

I'm using a web-worker to load a .json file of an animated 3D model. For each of the big arrays (vertices, normals, etc.), I'm transferring an Float32Array buffer back to the UI thread. Since such buffers are transferable objects, this will take…
mhelvens
  • 4,225
  • 4
  • 31
  • 55
3
votes
0 answers

XHR responseType = 'arraybuffer' does not work in Firefox

function getAudio(aUrl) { var deferred = $.Deferred(); // ajax is not capable of arraybuffer var xhr = new XMLHttpRequest(); xhr.responseType = 'arraybuffer'; xhr.open('GET', aUrl, true); // request succeeded …