diff --git a/README.md b/README.md old mode 100755 new mode 100644 index 80fd4977b588979a7de87b31c76caa4d14ae75e6..6530020343bc41f9ec56e4fea6eea740295f630d --- a/README.md +++ b/README.md @@ -1,22 +1,23 @@ # Audio -- [Introduction](#section119mcpsimp) - - [Basic Concepts](#section122mcpsimp) - -- [Directory Structure](#section179mcpsimp) -- [Usage Guidelines](#section112738505318) -- [Repositories Involved](#section340mcpsimp) - -## Introduction - -The **audio\_standard** repository supports the development of audio services. You can use this module to manage audio volume. + - [Introduction](#introduction) + - [Basic Concepts](#basic-concepts) + - [Directory Structure](#directory-structure) + - [Usage Guidelines](#usage-guidelines) + - [Audio Playback](#audio-playback) + - [Audio Recording](#audio-recording) + - [Audio Management](#audio-management) + - [Repositories Involved](#repositories-involved) + +## Introduction +The **audio\_standard** repository is used to implement audio-related features, including audio playback, recording, volume management and device management. **Figure 1** Position in the subsystem architecture ![](figures/en-us_image_0000001152315135.png) -### Basic Concepts +### Basic Concepts - **Sampling** @@ -38,58 +39,119 @@ Audio data is in stream form. For the convenience of audio algorithm processing Pulse code modulation \(PCM\) is a method used to digitally represent sampled analog signals. It converts continuous-time analog signals into discrete-time digital signal samples. -## Directory Structure +## Directory Structure The structure of the repository directory is as follows: ``` /foundation/multimedia/audio_standard # Audio code ├── frameworks # Framework code -│ ├── innerkitsimpl # Internal interfaces implementation -│ └── kitsimpl # External interfaces implementation -├── interfaces # Interfaces code -│ ├── innerkits # Internal interfaces -│ └── kits # External interfaces +│ ├── innerkitsimpl # Internal Native API Implementation. +| | Pulseaudio and libsnd file build configuration.pulseaudio-hdi modules +│ └── kitsimpl # External JS API Implementation +├── interfaces # Interfaces +│ ├── innerkits # Internal Native APIs +│ └── kits # External JS APIs ├── sa_profile # Service configuration profile ├── services # Service code ├── LICENSE # License file └── ohos.build # Build file ``` -## Usage Guidelines - -1. Obtain an **AudioManager** instance. +## Usage Guidelines +### Audio Playback +You can use APIs provided in this repository to convert audio data into audible analog signals, play the audio signals using output devices, and manage playback tasks. The following steps describe how to use **AudioRenderer** to develop the audio playback function: +1. Use **Create** API with required stream type to get **AudioRenderer** instance. + ``` + AudioStreamType streamType = STREAM_MUSIC; // example stream type + std::unique_ptr audioRenderer = AudioRenderer::Create(streamType); + ``` +2. (Optional) Static APIs **GetSupportedFormats**(), **GetSupportedChannels**(), **GetSupportedEncodingTypes**(), **GetSupportedSamplingRates**() can be used to get the supported values of the params. +3. To Prepare the device, call **SetParams** on the instance. + ``` + AudioRendererParams rendererParams; + rendererParams.sampleFormat = SAMPLE_S16LE; + rendererParams.sampleRate = SAMPLE_RATE_44100; + rendererParams.channelCount = STEREO; + rendererParams.encodingType = ENCODING_PCM; + audioRenderer->SetParams(rendererParams); + ``` +4. (Optional) use audioRenderer->**GetParams**(rendererParams); to validate SetParams +5. Call **audioRenderer->Start()** function on the AudioRenderer instance to start the playback task. +6. Get the buffer length to be written, using **GetBufferSize** API . + ``` + audioRenderer->GetBufferSize(bufferLen); + ``` +7. Read the audio data to be played from the source(example audio file) and transfer it into the bytes stream. Call the **Write** function repeatedly to write the render data. ``` - const audioManager = audio.getAudioManager(); + bytesToWrite = fread(buffer, 1, bufferLen, wavFile); + while ((bytesWritten < bytesToWrite) && ((bytesToWrite - bytesWritten) > minBytes)) { + bytesWritten += audioRenderer->Write(buffer + bytesWritten, bytesToWrite - bytesWritten); + if (bytesWritten < 0) + break; + } ``` +8. Call audioRenderer->**Drain**() to drain the playback stream. -2. Obtain the audio stream volume. +9. Call audioRenderer->**Stop()** function to Stop rendering. +10. After the playback task is complete, call the audioRenderer->**Release**() function on the AudioRenderer instance to release the resources. +Provided the basic playback usecase above. Please refer [**audio_renderer.h**](https://gitee.com/openharmony/multimedia_audio_standard/interfaces/innerkits/native/audiorenderer/include/audio_renderer.h) and [**audio_info.h**](https://gitee.com/openharmony/multimedia_audio_standard/interfaces/innerkits/native/audiocommon/include/audio_info.h) for more APIs. + + +### Audio Recording +You can use the APIs provided in this repository for your application to record voices using input devices, convert the voices into audio data, and manage recording tasks. The following steps describe how to use AudioReorder to develop the audio recording function: + +1. Use **Create** API with required stream type to get **AudioRecorder** instance. ``` - audioManager.getVolume(audio.AudioVolumeType.MEDIA, (err, value) => { - if (err) { - console.error(`failed to get volume ${err.message}`); - return; - } - console.log(`Media getVolume successful callback`); - }); + AudioStreamType streamType = STREAM_MUSIC; + std::unique_ptr audioRecorder = AudioRecorder::Create(streamType); ``` +2. (Optional) Static APIs **GetSupportedFormats**(), **GetSupportedChannels**(), **GetSupportedEncodingTypes**(), **GetSupportedSamplingRates()** can be used to get the supported values of the params. +3. To Prepare the device, call **SetParams** on the instance. + ``` + AudioRecorderParams recorderParams; + recorderParams.sampleFormat = SAMPLE_S16LE; + recorderParams.sampleRate = SAMPLE_RATE_44100; + recorderParams.channelCount = STEREO; + recorderParams.encodingType = ENCODING_PCM; -3. Set the audio stream volume. - + audioRecorder->SetParams(recorderParams); ``` - audioManager.setVolume(audio.AudioVolumeType.MEDIA, 30, (err)=>{ - if (err) { - console.error(`failed to set volume ${err.message}`); - return; - } - console.log(`Media setVolume successful callback`); - }) +4. (Optional) use audioRecorder->**GetParams**(recorderParams) to validate SetParams() +5. Call audioRenderer->**Start**() function on the AudioRecorder instance to start the recording task. +6. Get the buffer length to be read, using **GetBufferSize** API. ``` + audioRecorder->GetBufferSize(bufferLen); + ``` +7. Read the recorded audio data and convert it to a byte stream. Call the read function repeatedly to read data untill you want to stop recording + ``` + bytesRead = audioRecorder->Read(*buffer, bufferLen, isBlocking); // set isBlocking = true/false for blocking/non-blocking read + while (numBuffersToRecord) { + bytesRead = audioRecorder->Read(*buffer, bufferLen, isBlockingRead); + if (bytesRead < 0) { + break; + } else if (bytesRead > 0) { + fwrite(buffer, size, bytesRead, recFile); // example shows writes the recored data into a file + numBuffersToRecord--; + } + } + ``` +8. (Optional) Call audioRecorder->**Flush**() to flush the record buffer of this stream. +9. Call the audioRecorder->**Stop**() function on the AudioRecorder instance to stop the recording. +10. After the recording task is complete, call the audioRecorder->**Release**() function on the AudioRecorder instance to release resources. + +Provided the basic recording usecase above. Please refer [**audio_recorder.h**](https://gitee.com/openharmony/multimedia_audio_standard/interfaces/innerkits/native/audiorecorder/include/audio_recorder.h) and [**audio_info.h**](https://gitee.com/openharmony/multimedia_audio_standard/interfaces/innerkits/native/audiocommon/include/audio_info.h) for more APIs. + +### Audio Management +JS apps can use the APIs provided by audio manager to control the volume and the device.\ +Please refer the following for JS usage of audio volume and device management: + https://gitee.com/openharmony/docs/blob/master/en/application-dev/js-reference/audio-management.md -## Repositories Involved -multimedia\_audio\_standard +## Repositories Involved +[multimedia\_audio\_standard](https://gitee.com/openharmony/multimedia_audio_standard)\ +[multimedia\_media\_standard](https://gitee.com/openharmony/multimedia_media_standard) diff --git a/interfaces/kits/js/audio_manager/@ohos.multimedia.audio.d.ts b/interfaces/kits/js/audio_manager/@ohos.multimedia.audio.d.ts index 38c2edc5ee0bfaf606fbdd60cb2e9998e4eeb42a..724a1ad6d03d4dc9d79bca875c728ee706e41c20 100644 --- a/interfaces/kits/js/audio_manager/@ohos.multimedia.audio.d.ts +++ b/interfaces/kits/js/audio_manager/@ohos.multimedia.audio.d.ts @@ -29,24 +29,6 @@ declare namespace audio { * @devices */ function getAudioManager(): AudioManager; - /** - * Obtains an SoundPlayer instance. - * @sysCap SystemCapability.Multimedia.Audio - * @devices - */ - function createSoundPlayer(): SoundPlayer; - /** - * Obtains an ToneDescriptor instance. - * @sysCap SystemCapability.Multimedia.Audio - * @devices - */ - function createToneDescriptor(tone: ToneType): ToneDescriptor; - /** - * Obtains an SoundEffectBuilder instance. - * @sysCap SystemCapability.Multimedia.Audio - * @devices - */ - function getSoundEffectBuilder(): SoundEffectBuilder; /** * Enumerates audio stream types. @@ -148,122 +130,7 @@ declare namespace audio { */ RINGER_MODE_VIBRATE = 2, } - /** - * 呼叫状态枚举. - * @devices - * @sysCap SystemCapability.Multimedia.Audio - */ - enum CallState { - /** - * 空闲状态 - */ - IDLE = 0, - /** - * 打电话状态 - */ - IN_CALL = 1, - /** - * 处于voip状态 - */ - IN_VOIP = 2, - /** - * 铃声状态 - */ - RINGTONE = 3, - } - /** - * 音频编码方式枚举. - * @devices - * @sysCap SystemCapability.Multimedia.Audio - */ - enum AudioEncodingFormat { - /** - * 默认 - */ - ENCODING_DEFAULT = 0, - /** - * 无效 - */ - ENCODING_INVALID = 1, - /** - * mp3 - */ - ENCODING_MP3 = 2, - /** - * pcm16bit - */ - ENCODING_PCM_16BIT = 3, - /** - * pcm8bit - */ - ENCODING_PCM_8BIT = 4, - /** - * pcmfloat - */ - ENCODING_PCM_FLOAT = 5, - } - /** - * 音频内容枚举. - * @devices - * @sysCap SystemCapability.Multimedia.Audio - */ - enum ContentType { - /** - * 电影 - */ - CONTENT_TYPE_MOVIE = 0, - /** - * 音乐 - */ - CONTENT_TYPE_MUSIC = 1, - /** - * 可视化 - */ - CONTENT_TYPE_SONIFICATION = 2, - /** - * 演讲 - */ - CONTENT_TYPE_SPEECH = 3, - /** - * 未知 - */ - CONTENT_TYPE_UNKNOWN = 4, - } - enum InterruptType { - /** - * 静音 - */ - INTERRUPT_HINT_DUCK = 0, - /** - * 空 - */ - INTERRUPT_HINT_NONE = 1, - /** - * 暂停 - */ - INTERRUPT_HINT_PAUSE = 2, - /** - * 重新开始 - */ - INTERRUPT_HINT_RESUME = 3, - /** - * 停止 - */ - INTERRUPT_HINT_STOP = 4, - /** - * 不静音 - */ - INTERRUPT_HINT_UNDUCK = 5, - /** - * 开始 - */ - INTERRUPT_TYPE_BEGIN = 6, - /** - * 结束 - */ - INTERRUPT_TYPE_END = 7, - } /** * Manages audio volume and audio device information. * @devices @@ -354,30 +221,6 @@ declare namespace audio { * @devices */ setRingerMode(mode: AudioRingMode): Promise; - /** - * 获取主输出帧数,回调方式返回帧数。 - * @sysCap SystemCapability.Multimedia.Audio - * @devices - */ - getMasterOutputFrameCount(callback: AsyncCallback): void; - /** - * 获取主输出帧数,promise方式返回帧数。 - * @sysCap SystemCapability.Multimedia.Audio - * @devices - */ - getMasterOutputFrameCount(): Promise; - /** - * 获取主输出采样率,回调方式返回采样率。 - * @sysCap SystemCapability.Multimedia.Audio - * @devices - */ - getMasterOutputSampleRate(callback: AsyncCallback): void; - /** - * 获取主输出采样率,promise方式返回采样率。 - * @sysCap SystemCapability.Multimedia.Audio - * @devices - */ - getMasterOutputSampleRate(): Promise; /** * 判断流是否静音,回调方式返回。 * @sysCap SystemCapability.Multimedia.Audio @@ -414,42 +257,18 @@ declare namespace audio { * @devices */ isMicrophoneMute(): Promise; - /** - * 判断主设备是否静音,回调方式返回。 - * @sysCap SystemCapability.Multimedia.Audio - * @devices - */ - isMasterMute(callback: AsyncCallback): void; //不倾向与实现 - /** - * 判断主设备是否静音,promise方式返回。 - * @sysCap SystemCapability.Multimedia.Audio - * @devices - */ - isMasterMute(): Promise; //不倾向与实现 /** * 设置流静音,回调方式返回。 * @sysCap SystemCapability.Multimedia.Audio * @devices */ - setStreamMute(volumeType: AudioVolumeType, mute: boolean, callback: AsyncCallback) : void; + setStreamMute(volumeType: AudioVolumeType, mute: boolean, callback: AsyncCallback) : void; /** * 设置流静音,promise方式返回。 * @sysCap SystemCapability.Multimedia.Audio * @devices */ setStreamMute(volumeType: AudioVolumeType, mute: boolean): Promise; - /** - * 设置主设备静音,回调方式返回。 - * @sysCap SystemCapability.Multimedia.Audio - * @devices - */ - setMasterMute(mute: boolean, callback: AsyncCallback): void; //不倾向与实现 - /** - * 设置主设备静音,promise方式返回。 - * @sysCap SystemCapability.Multimedia.Audio - * @devices - */ - setMasterMute(mute: boolean): Promise; //不倾向与实现 /** * 设置麦克风是否静音,回调方式返回。 * @sysCap SystemCapability.Multimedia.Audio @@ -486,30 +305,6 @@ declare namespace audio { * @devices */ setDeviceActive(deviceType: DeviceType, active: boolean): Promise; - /** - * 连接蓝牙设备,回调方式返回。 - * @sysCap SystemCapability.Multimedia.Audio - * @devices - */ - connectBluetoothSco(callback: AsyncCallback): void; - /** - * 连接蓝牙设备,promise方式返回。 - * @sysCap SystemCapability.Multimedia.Audio - * @devices - */ - connectBluetoothSco(): Promise; - /** - * 断开蓝牙设备,回调方式返回。 - * @sysCap SystemCapability.Multimedia.Audio - * @devices - */ - disconnectBluetoothSco(callback: AsyncCallback): void; - /** - * 断开蓝牙设备,promise方式返回。 - * @sysCap SystemCapability.Multimedia.Audio - * @devices - */ - disconnectBluetoothSco(): Promise; /** * 获取音频参数,回调方式返回。 * @sysCap SystemCapability.Multimedia.Audio @@ -534,60 +329,6 @@ declare namespace audio { * @devices */ setAudioParameter(key: string, value: string): Promise; - /** - * 获取打电话状态,回调方式返回。 - * @sysCap SystemCapability.Multimedia.Audio - * @devices - */ - getCallState(callback: AsyncCallback): void; - /** - * 获取打电话状态,promise方式返回。 - * @sysCap SystemCapability.Multimedia.Audio - * @devices - */ - getCallState(): Promise; - /** - * 设置打电话状态,回调方式返回。 - * @sysCap SystemCapability.Multimedia.Audio - * @devices - */ - setCallState(callState: CallState, callback: AsyncCallback): void; - /** - * 设置打电话状态,promise方式返回。 - * @sysCap SystemCapability.Multimedia.Audio - * @devices - */ - setCallState(callState: CallState): Promise; - /** - * 激活音频中断。 - * @sysCap SystemCapability.Multimedia.Audio - * @devices - */ - activateAudioInterrupt(interrupt: AudioInterrupt): void; - /** - * 不激活音频中断。 - * @sysCap SystemCapability.Multimedia.Audio - * @devices - */ - deactivateAudioInterrupt(interrupt: AudioInterrupt): void; - /** - * 监听音频中断。 - * @sysCap SystemCapability.Multimedia.Audio - * @devices - */ - on(type: 'interrupt', callback: Callback): void; - /** - * 监听错误消息。 - * @sysCap SystemCapability.Multimedia.Audio - * @devices - */ - on(type: 'error', callback: ErrorCallback): void; - /** - * 监听设备变化。 - * @sysCap SystemCapability.Multimedia.Audio - * @devices - */ - on(type: 'deviceChange', callback: Callback): void; } /** @@ -596,51 +337,6 @@ declare namespace audio { * @sysCap SystemCapability.Multimedia.Audio */ interface AudioDeviceDescriptor { - /** - * id - * @devices - */ - id: number; - /** - * 名字 - * @devices - */ - name: string; - /** - * 地址 - * @devices - */ - address: string; - /** - * 采样率 - * @devices - */ - sampleRate: Array; - /** - * 通道数 - * @devices - */ - channelCounts: Array>; - /** - * 通道的mask序列 - * @devices - */ - channelIndexMasks: Array; - /** - * 通道的mask - * @devices - */ - channelMasks: Array; - /** - * 哈希值 - * @devices - */ - hashCode: number; - /** - * 编码方式 - * @devices - */ - encodeFormat: Array; /** * Audio device role * @devices @@ -652,63 +348,6 @@ declare namespace audio { */ readonly deviceType: DeviceType; } - /** - * 音频通道的类型 - * @devices - * @sysCap SystemCapability.Multimedia.Audio - */ - enum ChannelMask { - /** - * mono - */ - CHANNEL_IN_MONO = 0, - /** - * stereo - */ - CHANNEL_IN_STEREO = 1, - /** - * 无效 - */ - CHANNEL_INVALID = 2, - } - /** - * 音频中断。 - * @devices - * @sysCap SystemCapability.Multimedia.Audio - */ - interface AudioInterrupt { - /** - * 音频流类型 - * @sysCap SystemCapability.Multimedia.Audio - * @devices - */ - streamType: AudioVolumeType; - /** - * 音频内容 - * @devices - */ - contentType: ContentType; - /** - * 暂停时是否静音 - * @devices - */ - pauseWhenDucked: boolean; - /** - * 中断类型 - * @devices - */ - streamFlag: InterruptType; - /** - * 音频通道的mask - * @devices - */ - chanelMask: ChannelMask; - /** - * 音频编码方式 - * @devices - */ - encodingFormat: AudioEncodingFormat; - } /** * A queue of AudioDeviceDescriptor, which is read-only. @@ -716,575 +355,6 @@ declare namespace audio { * @sysCap SystemCapability.Multimedia.Audio */ type AudioDeviceDescriptors = Array>; - /** - * 短音类型。 - * @devices - * @sysCap SystemCapability.Multimedia.Audio - */ - enum SoundType { - /** - * 点击 - */ - KEY_CLICK = 0, - /** - * 删除 - */ - KEYPRESS_DELETE = 1, - /** - * 无效 - */ - KEYPRESS_INVALID = 2, - /** - * 返回 - */ - KEYPRESS_RETURN = 3, - /** - * 空格键 - */ - KEYPRESS_SPACEBAR = 4, - /** - * 标准 - */ - KEYPRESS_STANDARD = 5, - /** - * 下 - */ - NAVIGATION_DOWN = 6, - /** - * 左 - */ - NAVIGATION_LEFT = 7, - /** - * 右 - */ - NAVIGATION_RIGHT = 8, - /** - * 上 - */ - NAVIGATION_UP = 9, - } - /** - * 短音播放器。 - * @devices - * @sysCap SystemCapability.Multimedia.Audio - */ - interface SoundPlayer { - /** - * 读取短音,返回id,回调方式返回。 - * @sysCap SystemCapability.Multimedia.Audio - * @devices - */ - loadSound(path: string, callback: AsyncCallback): void; - /** - * 读取短音,返回id,promise方式返回。 - * @sysCap SystemCapability.Multimedia.Audio - * @devices - */ - loadSound(path: string): Promise; - /** - * 通过tone读取短音,返回id,回调方式返回。 - * @sysCap SystemCapability.Multimedia.Audio - * @devices - */ - loadSoundByTone(tone: ToneType, durationMs: number, callback: AsyncCallback): void; - /** - * 通过tone读取短音,返回id,promise方式返回。 - * @sysCap SystemCapability.Multimedia.Audio - * @devices - */ - loadSoundByTone(tone: ToneType, durationMs: number): Promise; - /** - * 通过流类型读取短音,返回id,回调方式返回。 - * @sysCap SystemCapability.Multimedia.Audio - * @devices - */ - loadSoundByStream(audioStream: AudioVolumeType, volume: number, callback: AsyncCallback); - /** - * 通过流类型读取短音,返回id,promise方式返回。 - * @sysCap SystemCapability.Multimedia.Audio - * @devices - */ - loadSoundByStream(audioStream: AudioVolumeType, volume: number): Promise; - /** - * 删除短音。 - * @sysCap SystemCapability.Multimedia.Audio - * @devices - */ - unloadSound(soundId: number); - /** - * 播放短音,回调方式返回id。 - * @sysCap SystemCapability.Multimedia.Audio - * @devices - */ - play(soundId: number, options: SoundOptions, callback: AsyncCallback): void; - /** - * 播放短音,回调方式返回id。 - * @sysCap SystemCapability.Multimedia.Audio - * @devices - */ - play(soundId: number, callback: AsyncCallback): void; - /** - * 播放短音,promise方式返回id。 - * @sysCap SystemCapability.Multimedia.Audio - * @devices - */ - play(soundId: number, options?: SoundOptions): Promise; - /** - * 暂停短音。 - * @sysCap SystemCapability.Multimedia.Audio - * @devices - */ - pause(taskId: number): void; - /** - * 暂停所有短音。 - * @sysCap SystemCapability.Multimedia.Audio - * @devices - */ - pauseAll(): void; - /** - * 重新开始短音。 - * @sysCap SystemCapability.Multimedia.Audio - * @devices - */ - resume(taskId: number): void; - /** - * 重新开始所有短音。 - * @sysCap SystemCapability.Multimedia.Audio - * @devices - */ - resumeAll(): void; - /** - * 停止短音。 - * @sysCap SystemCapability.Multimedia.Audio - * @devices - */ - stop(taskId: number): void; - /** - * 设置参数。 - * @sysCap SystemCapability.Multimedia.Audio - * @devices - */ - setOptions(taskId: number, options: SoundOptions): void; - /** - * 释放。 - * @sysCap SystemCapability.Multimedia.Audio - * @devices - */ - release(): void; - /** - * 监听暂停消息。 - * @sysCap SystemCapability.Multimedia.Audio - * @devices - */ - on(type: 'pause', callback: Callback): void; - /** - * 监听暂停所有消息。 - * @sysCap SystemCapability.Multimedia.Audio - * @devices - */ - on(type: 'pauseAll', callback: Callback): void; - /** - * 监听重新开始消息。 - * @sysCap SystemCapability.Multimedia.Audio - * @devices - */ - on(type: 'resume', callback: Callback): void; - /** - * 监听重新开始所有的消息。 - * @sysCap SystemCapability.Multimedia.Audio - * @devices - */ - on(type: 'resumeAll', callback: Callback): void; - /** - * 监听暂停的消息。 - * @sysCap SystemCapability.Multimedia.Audio - * @devices - */ - on(type: 'stop', callback: Callback): void; - /** - * 监听参数变化的消息。 - * @sysCap SystemCapability.Multimedia.Audio - * @devices - */ - on(type: 'optionsChange', callback: Callback): void; - /** - * 监听完成的消息。 - * @sysCap SystemCapability.Multimedia.Audio - * @devices - */ - on(type: 'complete', callback: Callback): void; - /** - * 监听错误消息。 - * @sysCap SystemCapability.Multimedia.Audio - * @devices - */ - on(type: 'error', callback: ErrorCallback): void; - /** - * 监听释放的消息。 - * @sysCap SystemCapability.Multimedia.Audio - * @devices - */ - on(type: 'release', callback: Callback): void; - } - /** - * 短音参数。 - * @devices - * @sysCap SystemCapability.Multimedia.Audio - */ - interface SoundOptions { - /** - * 循环次数 - * @devices - */ - loopNumber: number; - /** - * 速率 - * @devices - */ - speed: number; - /** - * 音量 - * @devices - */ - volumes: SoundVolumes; - /** - * 优先级 - * @devices - */ - priority: number; - } - /** - * 短音音量 - * @devices - * @sysCap SystemCapability.Multimedia.Audio - */ - interface SoundVolumes { - /** - * 左声道 - * @devices - */ - left: number; - /** - * 右声道 - * @devices - */ - right: number; - } - /** - * tone类型 - * @devices - * @sysCap SystemCapability.Multimedia.Audio - */ - enum ToneType { - /** - * DTMF_0 - */ - DTMF_0 = 0, - /** - * DTMF_1 - */ - DTMF_1 = 1, - /** - * DTMF_2 - */ - DTMF_2 = 2, - /** - * DTMF_3 - */ - DTMF_3 = 3, - /** - * DTMF_4 - */ - DTMF_4 = 4, - /** - * DTMF_5 - */ - DTMF_5 = 5, - /** - * DTMF_6 - */ - DTMF_6 = 6, - /** - * DTMF_7 - */ - DTMF_7 = 7, - /** - * DTMF_8 - */ - DTMF_8 = 8, - /** - * DTMF_9 - */ - DTMF_9 = 9, - /** - * DTMF_A - */ - DTMF_A = 10, - /** - * DTMF_B - */ - DTMF_B = 11, - /** - * DTMF_C - */ - DTMF_C = 12, - /** - * DTMF_D - */ - DTMF_D = 13, - /** - * DTMF_P - */ - DTMF_P = 14, - /** - * DTMF_S - */ - DTMF_S = 15, - /** - * PROP_PROMPT - */ - PROP_PROMPT = 16, - /** - * SUP_CALL_WAITING - */ - SUP_CALL_WAITING = 17, - } - /** - * tone描述 - * @devices - * @sysCap SystemCapability.Multimedia.Audio - */ - interface ToneDescriptor { - /** - * tone类型 - * @devices - */ - toneType: ToneType; - /** - * 高频 - * @devices - */ - highFrequency: number; - /** - * 低频 - * @devices - */ - lowFrequency: number; - } - /** - * 声音特效模式。 - * @devices - * @sysCap SystemCapability.Multimedia.Audio - */ - enum SoundEffectMode { - /** - * 辅助 - */ - SOUND_EFFECT_MODE_AUXILIARY = 0, - /** - * 插入 - */ - SOUND_EFFECT_MODE_INSERT = 1, - /** - * 待加工 - */ - SOUND_EFFECT_MODE_PRE_PROCESSING = 2, - } - /** - * 声音特效类型。 - * @devices - * @sysCap SystemCapability.Multimedia.Audio - */ - enum SoundEffectType { - /** - * AE - */ - SOUND_EFFECT_TYPE_AE = 0, - /** - * EC - */ - SOUND_EFFECT_TYPE_EC = 1, - /** - * GC - */ - SOUND_EFFECT_TYPE_GC = 2, - /** - * 无效 - */ - SOUND_EFFECT_TYPE_INVALID = 3, - /** - * NS - */ - SOUND_EFFECT_TYPE_NS = 4, - } - /** - * 声音特效衍生类型。 - * @devices - * @sysCap SystemCapability.Multimedia.Audio - */ - enum SoundEffectDerivative { - /** - * GAIN_CONTRAL_EFFECT - */ - GAIN_CONTRAL_EFFECT = 0, - /** - * ECHO_CANCELER_EFFECT - */ - ECHO_CANCELER_EFFECT = 1, - /** - * NOISE_SUPPRESSOR_EFFECT - */ - NOISE_SUPPRESSOR_EFFECT = 2, - } - /** - * 声音特效创建器。 - * @devices - * @sysCap SystemCapability.Multimedia.Audio - */ - interface SoundEffectBuilder { - /** - * 获取可创建的声音特效,回调方式返回。 - * @sysCap SystemCapability.Multimedia.Audio - * @devices - */ - acquireEffects(callback: AsyncCallback>): void; - /** - * 获取可创建的声音特效,promise方式返回。 - * @sysCap SystemCapability.Multimedia.Audio - * @devices - */ - acquireEffects(): Promise>; - /** - * 创建声音特效,回调方式返回。 - * @sysCap SystemCapability.Multimedia.Audio - * @devices - */ - create(options: EffectOptions, callback: AsyncCallback): void; - /** - * 创建声音特效,promise方式返回。 - * @sysCap SystemCapability.Multimedia.Audio - * @devices - */ - create(options: EffectOptions): Promise; - } - /** - * 声音特效。 - * @devices - * @sysCap SystemCapability.Multimedia.Audio - */ - interface SoundEffect { - /** - * 特效音模式 - * @devices - */ - mode: SoundEffectMode; - /** - * 名字 - * @devices - */ - name: string; - /** - * 类型 - * @devices - */ - type: SoundEffectType; - /** - * 衍生类型 - * @devices - */ - deriveType: SoundEffectDerivative; - /** - * uid - * @devices - */ - uid: string; - /** - * 激活 - * @sysCap SystemCapability.Multimedia.Audio - * @devices - */ - active(): void; - /** - * 停止 - * @sysCap SystemCapability.Multimedia.Audio - * @devices - */ - deactive(): void; - /** - * 释放 - * @sysCap SystemCapability.Multimedia.Audio - * @devices - */ - release(): void; - /** - * 监听激活的消息 - * @sysCap SystemCapability.Multimedia.Audio - * @devices - */ - on(type: 'active', callback: Callback): void; - /** - * 监听停止的消息 - * @sysCap SystemCapability.Multimedia.Audio - * @devices - */ - on(type: 'deactive', callback: Callback): void; - /** - * 监听释放的消息 - * @sysCap SystemCapability.Multimedia.Audio - * @devices - */ - on(type: 'release', callback: Callback): void; - /** - * 监听错误消息 - * @sysCap SystemCapability.Multimedia.Audio - * @devices - */ - on(type: 'error', callback: ErrorCallback): void; - } - /** - * 声音特效信息。 - * @devices - * @sysCap SystemCapability.Multimedia.Audio - */ - interface EffectInfo { - /** - * 衍生类型 - * @devices - */ - deriveType: SoundEffectDerivative; - /** - * 是否可获取 - * @devices - */ - isAvailable: boolean; - } - /** - * 声音特效选项。 - * @devices - * @sysCap SystemCapability.Multimedia.Audio - */ - interface EffectOptions { - /** - * 衍生类型 - * @devices - */ - deriveType: SoundEffectDerivative - /** - * 音频播放器 - * @devices - */ - audioPlayer?: AudioPlayer; - /** - * 视频播放器 - * @devices - */ - videoPlayer?: VideoPlayer; - /** - * 包名 - * @devices - */ - pkgName: string; - } } export default audio; \ No newline at end of file