java sound api_Java Sound API

Java Sound API 提供底层音频处理,包括simpled-audio和midi处理,通过javax.sound包实现。它支持多种音频数据传输方式,如stream、buffered和unbuffered。核心组件包括Mixer、Line(如Clip和SourceDataLine)、AudioSystem,用于音频输入输出、混音和文件操作。使用AudioSystem获取Mixer和Line,通过Line监听器响应状态变化。音频文件的读写和格式转换也是Java Sound API的重要功能。
摘要由CSDN通过智能技术生成

Java Sound API是javaSE平台提供底层的(low-level)处理声音接口。

例外,java也提供了简单的实用的高层媒体接口(higher-level) - JMF(Java Media Framework)。

Java Sound API 将需要处理的数字音频分为:simpled-audio和midi,

分别提供Package来处理它们:

javax.sound.simpled

javax.sound.midi

同时SOUND API还提供了第三方的扩展接口:

javax.sound.simpled.spi

javax.sound.midi.spi

*注:spi : service provider interface

Sampled Audio

采样音频(simpled-audio)不仅包含从模拟信号采样来的数字音频,还包括电脑合成的。

称作digital-audio更为合适。

为了能够让设备播放采样声音,程序需要处理 audio input, output device, audio data buffers。

还有混音处理(mix multiple streams of audio into one stream)。

SOUND API 可以使用3种方式传输声音数据:stream, buffered fashion, in-memory unbuffered fashion。

第三种方式适合数据量不大,能够一次载入的所有数据的情形。这样,声音的响应较快,循环和随机定位也会很简单。

使用SOUND API播放声音至少需要3样东西:

lformatted audio data,

la mixer,

la line.

Mixer

调音台

technically the Mixer itself is also a kind of Line

Line

音频数据管道。

Clip extends Line

将需要播放的音频数据装载进来。

preloads audio data from a sound file into clips

A Clip is a data line into which audio data can be loaded prior to playback. Because the data is

pre-loaded rather than streamed, the clip‘s duration is known before playback, and you can choose any

starting position in the media. Clips can be looped, meaning that upon playback, all the data between two

specified loop points will repeat a specified number of times, or indefinitely.

SourceDataLine extends Line

accept real-time stream of audio data

feed audio to the Mixer

A SourceDataLine receives audio data for playback. It provides methods for writing data to the

source data line‘s buffer for playback, and for determining how much data the line is prepared to receive

without blocking.

TargetDataLine

A TargetDataLine receives audio data from a mixer. Commonly, the mixer has captured audio data

from a port such as a microphone; it might process or mix this captured audio before placing the data in

the target data line‘s buffer. The Target

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值