필터 지우기
필터 지우기

How do I retreive the data, samples, from a audioplayer object

조회 수: 4 (최근 30일)
Jerry Gregoire
Jerry Gregoire 2013년 3월 22일
댓글: Walter Roberson 2022년 7월 22일
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?

답변 (4개)

Wayne King
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?
  댓글 수: 1
Jerry Gregoire
Jerry Gregoire 2013년 3월 25일
By SoundData I mean the samples that were used to create the object, (ie) y. So if I am given the object, I can extract y to do analysis. JG

댓글을 달려면 로그인하십시오.


Matt Tearle
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
Jerry Gregoire
Jerry Gregoire 2013년 3월 25일
Yeah, I thought of this. It is inefficient since the object already has the data. If I have to, I will do it this way. It would be nice though to have access to the data if I didn't create the object.
Matt Tearle
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
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.

Peter Urlings
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
Petros Oratiou 2022년 7월 22일
Does this mean that making a struct copy of an object will ignore all restrictions?
Walter Roberson
Walter Roberson 2022년 7월 22일
Yes, using struct() can violate access restrictions.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Audio and Video Data에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by