Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

websockets-streaming-audio

Package Overview
Dependencies
Maintainers
1
Versions
88
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

websockets-streaming-audio - npm Package Compare versions

Comparing version 0.2.6-14 to 0.2.6-15

notes.txt

2

package.json

@@ -38,3 +38,3 @@ {

"subdomain": "websockets-streaming-audio",
"version": "0.2.6-14"
"version": "0.2.6-15"
}

@@ -9,2 +9,17 @@ var communication_sockets = function() {

// var cb_from_client_to_server_back_to_client;
var cb_for_client;
// ---
// function forward_audio_buffer_to_player() {
// console.log("Corinde where U at ... here I am ... forward_audio_buffer_to_player");
// console.log("Corinde where U at ... here I am ... forward_audio_buffer_to_player");
// console.log("Corinde where U at ... here I am ... forward_audio_buffer_to_player");
// console.log("Corinde where U at ... here I am ... forward_audio_buffer_to_player");
// console.log("Corinde where U at ... here I am ... forward_audio_buffer_to_player");
// }
// ---------------------

@@ -36,2 +51,6 @@

// var property_key_callback = "callback_in_client_back_from_server";
// var cb_for_client;
// ---

@@ -54,9 +73,27 @@

// ---
/*
try {
received_json = JSON.parse(received_data);
var received_json = JSON.parse(event.data);
route_msg(received_json, received_data, ws);
console.log("received_json ", received_json);
if (typeof received_json.rss !== "undefined") {
updateStats(received_json); // send received data directly to browser screen
} else {
// this.cb_from_client_to_server_back_to_client.retrieved_cb = received_json.cb_client_to_server_to_client;
// console.log("received_json.cb_client_to_server_to_client ",
// received_json.cb_client_to_server_to_client);
// cb_for_client = received_json.cb_client_to_server_to_client;
// console.log("cb_for_client ", cb_for_client);
// cb_for_client();
}
} catch (error) {

@@ -67,9 +104,8 @@

console.log("Received received_json NON JSON though : ", received_data);
console.log("Received received_json NON JSON though : ", event.data);
}
*/
// ---
updateStats(JSON.parse(event.data)); // send received data directly to browser screen
// updateStats(JSON.parse(event.data)); // send received data directly to browser screen

@@ -101,2 +137,10 @@ } else if (event.data instanceof ArrayBuffer) {

cb_for_client(server_buffer);
// forward_audio_buffer_to_player();
// cb_from_client_to_server_back_to_client.callback();
// console.log("cb_from_client_to_server_back_to_client ", this.cb_from_client_to_server_back_to_client);
} else if (event.data instanceof Blob) { // binary bbb

@@ -179,7 +223,2 @@

function forward_audio_buffer_to_player() {
console.log("Corinde where U at ... here I am ... forward_audio_buffer_to_player");
}
function request_server_send_binary(requested_action, requested_source, given_callback) {

@@ -199,2 +238,4 @@

// this.cb_from_client_to_server_back_to_client.callback = given_callback;
var request_msg;

@@ -209,3 +250,3 @@ try {

requested_source : requested_source,
callback : given_callback
cb_client_to_server_to_client : given_callback
});

@@ -221,3 +262,3 @@

function socket_client(given_mode) {
function socket_client(given_mode, given_binary_data, given_callback) {

@@ -261,8 +302,19 @@ switch (given_mode) {

cb_for_client = given_callback;
var requested_action = "get_audio_buffer_from_server";
var requested_source = "Justice_Genesis_first_30_seconds.wav"; // get buffer of this from svr
var local_callback = "forward_audio_buffer_to_player";
request_server_send_binary(requested_action, requested_source, local_callback);
// var local_callback = "forward_audio_buffer_to_player";
// console.log("EARLY DAYS ");
// console.log("EARLY DAYS ");
// console.log("EARLY DAYS ");
// forward_audio_buffer_to_player();
// console.log("EARLY DAYS ");
// console.log("EARLY DAYS ");
// console.log("EARLY DAYS ");
request_server_send_binary(requested_action, requested_source, given_callback);
break;

@@ -269,0 +321,0 @@ }

@@ -138,2 +138,10 @@

console.log("received_json.cb_client_to_server_to_client ", received_json.cb_client_to_server_to_client);
console.log("received_json.cb_client_to_server_to_client ", received_json.cb_client_to_server_to_client);
console.log("received_json.cb_client_to_server_to_client ", received_json.cb_client_to_server_to_client);
console.log("received_json.cb_client_to_server_to_client ", received_json.cb_client_to_server_to_client);
console.log("received_json.cb_client_to_server_to_client ", received_json.cb_client_to_server_to_client);
console.log("populated buffer size ", audio_obj.buffer.length);

@@ -144,2 +152,8 @@

// curr_ws.send(received_json, {binary: false, mask: true}); // send text
curr_ws.send(given_request, {binary: false, mask: true}); // send text
// JSON.stringify
curr_ws.send(audio_obj.buffer, {binary: true, mask: true}); // OK good one

@@ -234,15 +248,11 @@ }));

var wrap_stats = function() {
var ID_timeout;
(function run() { // run immediately ... then repeat after delay
// code here
console.log("NOW calling wrap_stats");
ws.send(JSON.stringify(process.memoryUsage()), function() {});
var stats_id = setInterval(function() {
ID_timeout = setTimeout(run, 2500);
}());
ws.send(JSON.stringify(process.memoryUsage()), function() {});
}, 500); // server sends message to browser twice per second
};
var ID_timeout = setTimeout(wrap_stats, 20);
console.log("websocket connection open");

@@ -285,7 +295,4 @@

ws.on("close", function() {
console.log("websocket connection close")
// clearInterval(id)
clearInterval(wrap_stats.stats_id);
// clearInterval(run.stats_id);
// clearInterval(ID_write);
console.log("websocket connection close");
clearTimeout(ID_timeout);

@@ -292,0 +299,0 @@ });

@@ -43,4 +43,23 @@

gain_node.connect(audio_context.destination); // Connect gain node to speakers
};
// ---
function forward_audio_buffer_to_player(audio_obj_from_server) {
console.log("Corinde where U at ... here I am ... forward_audio_buffer_to_player");
console.log("Corinde where U at ... here I am ... forward_audio_buffer_to_player");
console.log("Corinde where U at ... here I am ... forward_audio_buffer_to_player");
console.log("Corinde where U at ... here I am ... forward_audio_buffer_to_player");
console.log("Corinde where U at ... here I am ... forward_audio_buffer_to_player");
if (typeof audio_obj_from_server !== "undefined") {
console.log("audio_obj_from_server.length ", audio_obj_from_server.length);
}
}
// ---
var gain_node;

@@ -878,2 +897,3 @@

var in_middle_of_playback = false;

@@ -903,3 +923,4 @@

var desired_buffer_obj = audio_process_obj.get_buffer(given_flavor);
// var desired_buffer_obj = audio_process_obj.get_buffer(given_flavor);
var desired_buffer_obj = {};

@@ -936,46 +957,57 @@ // if (desired_buffer_obj && desired_buffer_obj.buffer) {

case 3:
{
case 3 : {
console.log('about to send ELEPHANT Roar to server side size ',
desired_buffer_obj.buffer.length);
console.log('about to send ELEPHANT Roar to server side size ',
desired_buffer_obj.buffer.length);
// communication_sockets_obj.socket_client(3, desired_buffer_obj.buffer);
communication_sockets_obj.socket_client(3, desired_buffer_obj);
// communication_sockets_obj.socket_client(3, desired_buffer_obj.buffer);
communication_sockets.socket_client(3, desired_buffer_obj);
// ---
// ---
in_middle_of_playback = true;
in_middle_of_playback = true;
// ---
// ---
var this_glob_02 = audio_context.createScriptProcessor(BUFF_SIZE, 1, 1);
var this_glob_02 = audio_context.createScriptProcessor(BUFF_SIZE, 1, 1);
// init_synth_settings(this_glob_02);
setup_onaudioprocess_callback_render(this_glob_02, desired_buffer_obj.buffer,
desired_buffer_obj.size, set_false_in_middle_of_playback);
// init_synth_settings(this_glob_02);
setup_onaudioprocess_callback_render(this_glob_02, desired_buffer_obj.buffer,
desired_buffer_obj.size, set_false_in_middle_of_playback);
followup_fft(this_glob_02);
followup_fft(this_glob_02);
// ---
// ---
break;
}
break;
}
case 4:
{
case 4 : {
console.log('about to send genetic synth to server side size ',
desired_buffer_obj.size_buffer);
console.log('about to send genetic synth to server side size ',
desired_buffer_obj.size_buffer);
communication_sockets_obj.socket_client(4, desired_buffer_obj);
communication_sockets.socket_client(4, desired_buffer_obj);
break;
}
break;
}
// --- default
case 5 : {
console.log("get audio buffer from server");
communication_sockets.socket_client(4, desired_buffer_obj, forward_audio_buffer_to_player);
break;
}
default : {
console.error("ERROR - failed to match given_flavor ", given_flavor);
break;
}
}

@@ -1050,2 +1082,54 @@

function setup_streaming_onaudioprocess_callback(given_node) {
given_node.onaudioprocess = (function() {
return function(event) {
if (allow_synth) {
// console.log('inside main_glob callback onaudioprocess BUFF_SIZE ', BUFF_SIZE);
var synthesized_output_buffer;
// stens TODO - how to pass in own buffer instead of being given object: out so I can do a circular ring of such buffers
synthesized_output_buffer = event.outputBuffer.getChannelData(0); // stens TODO - do both channels not just left
var phi = 0,
dphi = 2.0 * Math.PI * given_node.sample_freq /
given_node.sample_rate;
for (var curr_sample = 0; curr_sample < given_node.BUFF_SIZE; curr_sample++, phi += dphi) {
synthesized_output_buffer[curr_sample] = Math.sin(phi);
}
given_node.sample_freq *= given_node.freq_factor;
if (given_node.sample_freq <
given_node.MIN_FREQ) {
given_node.freq_factor = given_node.increasing_freq_factor;
} else if (given_node.sample_freq > given_node.MAX_FREQ) {
given_node.freq_factor = given_node.decreasing_freq_factor;
}
// ---
// stens TODO - commented out below 20140811
// audio_display_obj.pipeline_buffer_for_time_domain_cylinder(synthesized_output_buffer,
// BUFF_SIZE, "providence_2");
}
};
}());
} // setup_streaming_onaudioprocess_callback
// ---
function setup_onaudioprocess_callback(given_node) {

@@ -1098,3 +1182,3 @@

}());
}
} // setup_onaudioprocess_callback

@@ -1225,5 +1309,7 @@ function setup_onaudioprocess_callback_render(given_node, render_this_buffer, render_size_buffer, done_callback) {

setup_onaudioprocess_callback(this_glob_01);
followup_fft(this_glob_01);
// followup_fft(this_glob_01);
this_glob_01.connect(gain_node);
was_anything_stopped = false; // reset for any possible subsequent playback

@@ -1230,0 +1316,0 @@

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc