Javascript 在WinJS应用程序中获取录制的声音表示
您好。我想使用HTML和JavaScript创建Windows 8应用程序,并希望录制声音并用图形实时表示声音变化。我遵循这一点,并能够记录 将声音转换为mp3文件。此外,我想实现的是附加到某个事件,该事件为我提供有关录音机声音的实时信息。然后利用这些数据,我想对其进行分析,取声音表现的所有或部分离散点, 例如,将它们转换为JSON,然后可视化这些信息。我拥有所有可用的资源,除非我无法获得实时表示。我调查了oMediaCapture对象(见下面的代码),但无法获得这样的功能。 然后我尝试使用stream,希望它能提供这样的功能。但当我尝试按照MSDN创建RandomAccessStream时,会出现异常 这是我的全部代码:Javascript 在WinJS应用程序中获取录制的声音表示,javascript,stream,media,winjs,Javascript,Stream,Media,Winjs,您好。我想使用HTML和JavaScript创建Windows 8应用程序,并希望录制声音并用图形实时表示声音变化。我遵循这一点,并能够记录 将声音转换为mp3文件。此外,我想实现的是附加到某个事件,该事件为我提供有关录音机声音的实时信息。然后利用这些数据,我想对其进行分析,取声音表现的所有或部分离散点, 例如,将它们转换为JSON,然后可视化这些信息。我拥有所有可用的资源,除非我无法获得实时表示。我调查了oMediaCapture对象(见下面的代码),但无法获得这样的功能。 然后我尝试使用st
(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);
}
那么,您是否看到了明显的错误,或者仅仅是方法错误?提前感谢您 致以最诚挚的问候,尼古拉·阿利皮耶夫看来这在WInJS当前的功能中是不可能的。为了能够获得音频实时信息,需要进行C++。这是微软。您还可以在Microsoft中看到我得到的答案没有文档化的方法来获取从WinRT录制和编码的音频数据。这就是你想要做的吗?谢谢你的快速回复。是的,这就是我要找的。在录音过程中获取声音数据。或者至少具有先将其录制到mp3,然后从文件中读取并用图形表示数据的功能。
(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);
}