
Get audio signal from audiplayer object
6 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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.
0 commentaires
Réponses (1)
Rajanya
le 18 Déc 2024
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.
You can refer to the documentation link below to learn more about how to use the 'struct' function on an object and its effects: https://www.mathworks.com/help/releases/R2021a/matlab/ref/struct.html?searchHighlight=struct&searchResultIndex=1#d123e1294862:~:text=s%20%3D%20struct(obj)%20creates,a%20warning%20when%20you%20use%20this%20syntax
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.
0 commentaires
Voir également
Catégories
En savoir plus sur Audio and Video Data dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!