Get audio signal from audiplayer object

9 visualizzazioni (ultimi 30 giorni)
dan bloodworth
dan bloodworth il 17 Mar 2021
Risposto: Rajanya il 18 Dic 2024 alle 11:37
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.

Risposte (1)

Rajanya
Rajanya il 18 Dic 2024 alle 11:37
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.

Community Treasure Hunt

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

Start Hunting!

Translated by