Questions tagged [arraybuffer]

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

597 questions
7
votes
2 answers

Receiving WebSocket ArrayBuffer data in the browser - receiving string instead

I have a node.js server application and a browser client. Sending ArrayBuffer data browser -> server works perfectly, but server -> browser results in a string "[object ArrayBuffer]" being received. This happens in the latest versions of both Chrome…
svinja
  • 5,495
  • 5
  • 25
  • 43
6
votes
1 answer

When I open a Salesforce Attachment it is downloaded but the pdf is empty

I am getting the attachment body using the Rest API. var config = { method: 'get', url: '/services/data/v48.0/sobjects/Attachment/00PD000000HQD68MAH/Body', headers: { …
6
votes
1 answer

Offset is outside the bounds of the DataView, the debugger shows it is inside the bounds

I get the error Offset is outside the bounds of the DataView for the following code let data = [...] // some array of Int16 let buf = new ArrayBuffer(data.length); let dataView = new DataView(buf); data.forEach((b, i) => { dataView.setInt16(i,…
Aivan Monceller
  • 4,636
  • 10
  • 42
  • 69
6
votes
1 answer

Javascript Fetch API with multiple ranges request get binary Float32Array data

I am using range request to read many 32 bit float from a large binary file, unfortunately the float I need from this file is at different part of the file, hence I need to do range request with multiple…
Terry
  • 533
  • 7
  • 17
6
votes
3 answers

How to write low-precision numbers (2-10 bits) to an array buffer / blob?

problem: in video-games there are tons of low precision numbers that can be packed together over the network to dramatically save bandwidth compared to sending strings. Strings are allocated to UTF-8 which uses 1 byte for each character. Ideally…
hydrix
  • 332
  • 2
  • 9
6
votes
1 answer

Convert ArrayBuffer into ImageData for drawing on canvas: optimization

I am streaming video over a WebSocket by sending each frame in the raw ImageData format (4 bytes per pixel in RGBA order). When I receive each frame on the client (as an ArrayBuffer), I want to paint this image directly onto the canvas as…
rvighne
  • 20,755
  • 11
  • 51
  • 73
6
votes
1 answer

Receive an ArrayBuffer on WebSocket (ws)

I would like to handle ArrayBuffer messages received from the client using ws. Client-side, I directly receive an ArrayBuffer thanks to ws.binaryType, but server-side, I don't receive an ArrayBuffer but something like this (string ?) : '< Buffer 00…
zbeyens
  • 321
  • 1
  • 5
  • 16
6
votes
1 answer

Reading/writing/copying an ArrayBuffer into another ArrayBuffer with an offset

Let's say I have an ArrayBuffer which is an mp4 file. I'd like to create a new ArrayBuffer with a few extra bytes to be used as header information, and then store the mp4 buffer in the remainder of the new ArrayBuffer. // ... assume the `data`…
Nick Jennings
  • 3,853
  • 6
  • 30
  • 45
6
votes
3 answers

store a json object in ArrayBuffer

Want to store a json object in ArrayBuffer function stringToUint(string) { var string = btoa(unescape(encodeURIComponent(string))), charList = string.split(''), uintArray = []; for (var i = 0; i < charList.length; i++) { …
Manish Kumar
  • 10,214
  • 25
  • 77
  • 147
6
votes
2 answers

Javascript: Sending arrayBuffer using XMLHttpRequest

I want to send a multipart form using XMLHttpRequest. The file I want to attach is a jpg file. Appending the file to the FormData object works fine. But I'd like to process the image file before sending it. Therefore I have a library that takes a…
bebo
  • 819
  • 1
  • 9
  • 26
6
votes
1 answer

Playing raw audio PCM samples in Web Audio

I have an array of sound samples (16-bit): [0, 120, 320, 120, 0, -100, -30000, 65, 2, 3, 10, ...] They range -32768 to 32767. I would like to be able to play the samples using the Web Audio API. I know that it expects the source buffer to be an…
Chris
  • 26,544
  • 5
  • 58
  • 71
6
votes
2 answers

merging / layering multiple ArrayBuffers into one AudioBuffer using Web Audio API

I need to layer looping .wav tracks that ultimately I will need to be able to turn on and off and keep in sync. First I load the tracks and stopped BufferLoader from turning the loaded arraybuffer into an AudioBuffer (hence the false) …
samrad
  • 132
  • 1
  • 7
5
votes
2 answers

Shuffling part of an ArrayBuffer in-place

I need to shuffle part of an ArrayBuffer, preferably in-place so no copies are required. For example, if an ArrayBuffer has 10 elements, and I want to shuffle elements 3-7: // Unshuffled ArrayBuffer of ints numbered 0-9 0, 1, 2, 3, 4, 5, 6, 7, 8,…
Nic Foster
  • 2,864
  • 1
  • 27
  • 45
5
votes
1 answer

Javascript - Converting between Unicode string and ArrayBuffer

Does somebody know a script that is able to convert a string to a ArrayBuffer using unicode encoding? I´m creating a browser-side eqivalent of the "Buffer" of node.js. The only encoding that is left is unicode. All others are done. Thanks for your…
Van Coding
  • 24,244
  • 24
  • 88
  • 132
5
votes
4 answers

Efficiently update a canvas with RGB or grayscale data (but not RGBA)

I have a that I'm updating every 100 ms with bitmap image data coming from a HTTP request: var ctx = canvas.getContext("2d"); setInterval(() => { fetch('/get_image_data').then(r => r.arrayBuffer()).then(arr => { var byteArray =…
Basj
  • 41,386
  • 99
  • 383
  • 673