Get recorded sound representation in WinJS Application

Hi, there.

I want to create Windows 8 app, using HTML and JavaScript, and want to record sound and represent real time the sound variation with a graphic. I followed this article and was able to record the sound to an mp3 file. What I want to achieve, in addition, is to attach to some event, that gives me real time information about the recorder sound. Then using that data I want to analyze it, take all or some of the discrete points of the sound representation, convert them to JSON (for example) and then visualize that information. I have all the available resources unless that I cannot get real time representation. I investigated the "oMediaCapture" object (see code below), but couldn't get such functionality. Then I've tried to use stream and hope that it will propose such functionality. But then I get exception when I try to create "RandomAccessStream", following the MSDN article

var stream = new Windows.Storage.Streams.RandomAccessStream();

Here is my full code:

(function InitSound() {
    var settings = initCaptureSettings();
    initMediaCapture(settings);
})();


function initCaptureSettings() {
    var captureInitSettings = null;
    captureInitSettings = new Windows.Media.Capture.MediaCaptureInitializationSettings();
    captureInitSettings.audioDeviceId = "";
    captureInitSettings.streamingCaptureMode = Windows.Media.Capture.StreamingCaptureMode.audio;
    captureInitSettings.realTimeModeEnabled = true;
    return captureInitSettings;
}

function initMediaCapture(captureInitSettings) {
    oMediaCapture = null;
    oMediaCapture = new Windows.Media.Capture.MediaCapture();
    oMediaCapture.initializeAsync(captureInitSettings).then(function (result) {
        createProfile();
    }, errorHandler);
}

function createProfile() {
    profile = Windows.Media.MediaProperties.MediaEncodingProfile.createMp3(Windows.Media.MediaProperties.AudioEncodingQuality.high);
}

function errorHandler(e) {

}

function recordSound() {
    var stream = new Windows.Storage.Streams.RandomAccessStream();
    oMediaCapture.startRecordToStreamAsync(profile, stream).then(function (result) {

    }, errorHandler);
    /*Windows.Storage.KnownFolders.videosLibrary.createFileAsync("checkMic.mp3", Windows.Storage.CreationCollisionOption.generateUniqueName).then(function (newFile) {
        storageFile = newFile;
        oMediaCapture.startRecordToStorageFileAsync(profile, storageFile).then(function (result) {

        }, errorHandler);
    });*/
}

function stopRecord() {
    //oMediaCapture.stopRecordAsync().then(function (result) {
    //  storageFile.openAsync(Windows.Storage.FileAccessMode.read).then(function (stream) {
    //      oMediaCapture.startRecordToStreamAsync(profile, stream).then(function (result) {

    //      }, errorHandler);
    //  });
    //}, errorHandler);
}

So do you see an obvious mistake or just the approach is wrong?

Thank you in advance!

Best regards,

Nikolay Alipiev

Answers


It seems that this is not possible with the current functionality of the WInJS. To be able to obtain audio real-time information, the C++ needs to take place. Here is the Microsoft sample. You can also see the answer I got in the Microsoft forum


Need Your Help

Check current Bluetooth discoverability state

android bluetooth android-button android-bluetooth

So, I have been cracking my head how to check current Bluetooth discoverability state. I want to deal with simple problem which is:

Flask - handling unicode text with werkzeug?

unicode http-headers flask werkzeug

So I am trying to have a browser download a file with a certain name, which is stored in a database. To prevent filename conflicts the file is saved on disk with a GUID, and when it comes time to