How do I retreive the data, samples, from a audioplayer object
4 次查看(过去 30 天)
显示 更早的评论
How do I retrieve the sample data from an audioplayer object. This seems like an obvious thing to allow, but I cannot find any information on it.
Example: AudObj = audioplayer(SoundData, Fs, N);
Now if I don't have access to SoundData, how can I retrieve it from AudObj?
0 个评论
回答(4 个)
Wayne King
2013-3-22
编辑:Wayne King
2013-3-22
I'm not sure what you mean by "you don't have access to SoundData"
What is SoundData?
Normally you feed audioplayer, the data vector from the MATLAB workspace.
Like:
load handel;
p = audioplayer(y, Fs);
Or are you passing it a handle from an audiorecorder object?
Matt Tearle
2013-3-22
编辑:Matt Tearle
2013-3-22
This seems like an unnecessarily inelegant hack, but you could always attach SoundData as AudObj's UserData property:
load handel;
player = audioplayer(y, Fs);
player.UserData = y;
clear y
y = player.UserData;
If you edit the audioplayer classdef, it appears that the actual audio data is "locked down" as a private property (called AudioData).
2 个评论
Matt Tearle
2013-3-25
I'm not sure it will be that inefficient. MATLAB generally does a lazy copy (just a reference unless the data is modified). Not sure if there's anything about being a private property of the object that changes that behavior.
But, yes, the issue of getting the object from someone/somewhere else is tricky. Not much you can do about that. Maybe you could submit an enhancement request.
Sean de Wolski
2013-3-27
编辑:Sean de Wolski
2013-3-27
The audioplayer data is stored in a property that has SetAccess and GetAccess attributes set to private
This can be seen by opening the audioplayer class.
I'll put in the enhancement request.
0 个评论
Peter Urlings
2020-6-18
编辑:Peter Urlings
2020-6-18
To retrieve the data from an audioplayer object use:
s=struct(AudObj)
SoundDataPullout = s.AudioData;
2 个评论
Petros Oratiou
2022-7-22
Does this mean that making a struct copy of an object will ignore all restrictions?
另请参阅
类别
在 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!