Get audio signal from audiplayer object

조회 수: 6 (최근 30일)
dan bloodworth
dan bloodworth 2021년 3월 17일
답변: Rajanya 2024년 12월 18일
Hi, so I've stored an audioplayer in a variable and wish to fetch the signal and frequency separately.
I know that getting the freqency is as simple as using get() on the 'SampleRate' property however, I'm not sure how to get the y signal.
Any help would be appreciated.

답변 (1개)

Rajanya
Rajanya 2024년 12월 18일
The ‘audioplayer’ object does not provide direct access to the audio or signal data, as it does not expose this data through any of its properties or methods.
However, as a workaround, a new structure can be created by calling ‘struct’ on the ‘audioplayer’ object which will expose all the public, private and protected properties of the class as the encapsulated information will no longer be maintained.
The below code shows the demonstration of the following:
player = audioplayer(sig,fs); %assuming sig (signal) and fs (rate) are available before object creation
player1 = struct(player); %call struct on player object
player2 = struct(player1.audioplayerImpl); % this audioplayerImpl is a hidden object of type
% 'audiovideo.internal.audioplayerDesktop' which becomes visible in the new struct ‘player1’.
% Calling struct on this exposes further properties.
On executing this, ‘player2’ reveals all properties, including ‘AudioData’, which stores the signal data.
This can be verified by:
isequal(sig, player2.AudioData) %to check if this matches the original signal
which results in a logical 1.
And for more details on `audioplayer`, you can visit its documentation page: https://www.mathworks.com/help/releases/R2021a/matlab/ref/audioplayer.html
Thanks! Hope this helps.

카테고리

Help CenterFile Exchange에서 Audio and Video Data에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by