Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
var mediaElement = null;

function getAudioDevices(){
var audioInDevices = "";
var audioOutDevices = "";
if(!navigator.mediaDevices.enumerateDevices){
console.log("enumerateDevices() not supported.");
}else{
navigator.mediaDevices.getUserMedia({audio: true, video: false}).then(s => {
navigator.mediaDevices.enumerateDevices().then((devices) => {
devices.forEach((device) => {
if(device.kind == "audioinput"){
audioInDevices = audioInDevices.concat(",", `${device.deviceId}`,",", `${device.label}`);
}
if(device.kind == "audiooutput"){
audioOutDevices = audioOutDevices.concat(",", `${device.groupId}`,",", `${device.label}`);
}
});
Module.loadAudioInDevices(audioInDevices);
Module.loadAudioOutDevices(audioOutDevices);
})
.catch((err) => {
console.error(`${err.name}: ${err.message}`);
});
});
}
}

function selectAudioIn(file){
if (navigator.getUserMedia){
navigator.getUserMedia(
{ audio: { deviceId: { exact: file } } },
function (audioIn){
if(mediaElement){
mediaElement.disconnect();
}
mediaElement = AUDIO.context.createMediaStreamSource(audioIn);
mediaElement.connect(AUDIO.stream);
},
function (error){
console.log("error creating audio in",error);
});
}
}

function selectAudioOut(file){
//AUDIO.context.setSinkId(file);
}
Original file line number Diff line number Diff line change
Expand Up @@ -174,26 +174,6 @@ var LibraryHTML5Audio = {
}
};

if (inputChannels > 0){
navigator.getUserMedia = navigator.getUserMedia ||
navigator.webkitGetUserMedia ||
navigator.mozGetUserMedia ||
navigator.msGetUserMedia;

if (navigator.getUserMedia){
navigator.getUserMedia(
{audio: true},
function (audioIn){
var mediaElement = AUDIO.context.createMediaStreamSource(audioIn);
mediaElement.connect(stream);
AUDIO.mediaElement = mediaElement;
},
function (error){
console.log("error creating audio in",error);
});
}
}

stream.connect(AUDIO.fft);
AUDIO.stream = stream;
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ endif
PLATFORM_LDFLAGS = -Wl --gc-sections --preload-file bin/data@data --emrun --bind --profiling-funcs -s USE_FREETYPE=1 -s EXPORTED_RUNTIME_METHODS=allocate -s ALLOW_MEMORY_GROWTH=1 -s MAX_WEBGL_VERSION=2
PLATFORM_LDFLAGS += --js-library $(OF_ADDONS_PATH)/ofxEmscripten/libs/html5video/lib/emscripten/library_html5video.js
PLATFORM_LDFLAGS += --js-library $(OF_ADDONS_PATH)/ofxEmscripten/libs/html5audio/lib/emscripten/library_html5audio.js
PLATFORM_LDFLAGS += --post-js $(OF_ADDONS_PATH)/ofxEmscripten/libs/html5audio/lib/emscripten/library_audioDeviceSelect.js

ifdef PROJECT_EMSCRIPTEN_TEMPLATE
PLATFORM_LDFLAGS += --shell-file $(PROJECT_EMSCRIPTEN_TEMPLATE)
Expand Down