AudioDestinationNode: thuộc tính maxChannelCount

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since April 2021.

Thuộc tính maxChannelCount của giao diện AudioDestinationNode là một unsigned long xác định số kênh tối đa mà thiết bị vật lý có thể xử lý.

Thuộc tính AudioNode.channelCount có thể được đặt trong khoảng từ 0 đến giá trị này (bao gồm cả hai đầu). Nếu maxChannelCount0, như trong OfflineAudioContext, thì không thể thay đổi số kênh.

Giá trị

Một unsigned long.

Ví dụ

Ví dụ sau sẽ thiết lập một đồ thị âm thanh, trong đó AudioDestinationNodemaxChannelCount bằng 2:

js
const audioCtx = new AudioContext();
const source = audioCtx.createMediaElementSource(myMediaElement);
source.connect(gainNode);
audioCtx.destination.maxChannelCount = 2;
gainNode.connect(audioCtx.destination);

Để xem một triển khai đầy đủ hơn, hãy xem một trong các ví dụ Web Audio của MDN, chẳng hạn như Voice-change-o-matic hoặc Violent Theremin.

Thông số kỹ thuật

Thông số kỹ thuật
Web Audio API
# dom-audiodestinationnode-maxchannelcount

Tương thích trình duyệt

Xem thêm