![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1821322/image.png)
Get audio signal from audiplayer object
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuestas (1)
Rajanya
el 18 de Dic. de 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.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1821322/image.png)
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 comentarios
Ver también
Categorías
Más información sobre Audio and Video Data en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!