Get audio signal from audiplayer object
2 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
回答 (1 件)
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.
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 件のコメント
参考
カテゴリ
Help Center および File Exchange で Audio and Video Data についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!