Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
T
turtlerob1
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Redmine
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Martin Karlsson
turtlerob1
Commits
23cac8f3
Commit
23cac8f3
authored
9 years ago
by
Fredrik Bagge Carlson
Browse files
Options
Downloads
Patches
Plain Diff
add analyze_source
parent
a0688535
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
analyze_source.m
+84
-0
84 additions, 0 deletions
analyze_source.m
state_machine.m
+14
-5
14 additions, 5 deletions
state_machine.m
with
98 additions
and
5 deletions
analyze_source.m
0 → 100644
+
84
−
0
View file @
23cac8f3
function
[
source_num
,
source_name
]
=
analyze_source
(
audio
,
fs
)
%WHICHSOURCE Estimates whether we're listening to source 1, 2, or 3
%
% 1) Male voice
% 2) Female
% 3) Trumpet
% Labels
source_labels
=
{
'male'
,
'female'
,
'trumpet'
};
% Hard coded training data for sources 1, 2, 3
% This is the mean pitch, calculated over the entire file, for each of the
% three sources. It doesn't reflect the fundamental frequency, and is not
% generalisable to files outside of the three in the training set.
mean_pitch
=
[
301
235
316
];
% USE AFE TO CALCULATE MEAN PITCH
% Set parameters
%%% Set parameters
% Request pitch processor
requests
=
{
'pitch'
};
% Parameters of auditory filterbank
fb_type
=
'gammatone'
;
fb_lowFreqHz
=
80
;
fb_highFreqHz
=
8000
;
fb_nChannels
=
16
;
% Parameters of innerhaircell processor
ihc_method
=
'dau'
;
% Parameters of autocorrelation processor
ac_wSizeSec
=
0.02
;
ac_hSizeSec
=
0.01
;
ac_clipAlpha
=
0.0
;
ac_K
=
2
;
ac_wname
=
'hann'
;
% Parameters of pitch processor
pi_rangeHz
=
[
80
400
];
% default: [80 400]
pi_confThres
=
0.7
;
pi_medianOrder
=
3
;
% Parameters
par
=
genParStruct
(
'fb_type'
,
fb_type
,
'fb_lowFreqHz'
,
fb_lowFreqHz
,
...
'fb_highFreqHz'
,
fb_highFreqHz
,
'fb_nChannels'
,
fb_nChannels
,
...
'ihc_method'
,
ihc_method
,
'ac_wSizeSec'
,
ac_wSizeSec
,
...
'ac_hSizeSec'
,
ac_hSizeSec
,
'ac_clipAlpha'
,
ac_clipAlpha
,
...
'ac_K'
,
ac_K
,
'ac_wname'
,
ac_wname
,
'pi_rangeHz'
,
pi_rangeHz
,
...
'pi_confThres'
,
pi_confThres
,
'pi_medianOrder'
,
pi_medianOrder
);
% Create a data object
dObj
=
dataObject
(
audio
,
fs
);
% Create a manager
mObj
=
manager
(
dObj
,
requests
,
par
);
% Request processing
mObj
.
processSignal
();
%%% GET THE DATA
% Get the data from the object
data
=
dObj
.
pitch
{
1
}
.
Data
(:);
% Get the mean pitch in this chunk of audio
meanvalue
=
mean
(
data
(
~
isnan
(
data
(:,
1
)),
1
));
%stdvalue = std(data(~isnan(data(:,1)),1));
%%% GUESS THE SOURCE
% Choose which source you think it is
[
~
,
source_num
]
=
min
(
abs
(
mean_pitch
-
meanvalue
));
% Get label
source_name
=
source_labels
{
source_num
};
This diff is collapsed.
Click to expand it.
state_machine.m
+
14
−
5
View file @
23cac8f3
d2r
=
180
/
pi
;
th_az
=
5
;
% Degrees
step_distance
=
0.1
;
% meters
% sendPosition.moveRelativePosition('map', moveFront, moveLeft, rotateClockwise);
th_dist
=
0.78
;
% sendPosition.moveRelativePosition('map', moveFront, moveLeft, rotateClockwise);
while
(
true
)
pause
(
0.01
)
...
...
@@ -26,10 +28,10 @@ while(true)
end
% We are there, analyze the source
source_
label
=
analyze_source
(
audio
);
audio
=
get_audio
(
12000
);
[
source_
num
,
source_name
]
=
analyze_source
(
audio
,
fs
);
display
(
'Source label determined'
)
disp
(
source_
label
)
disp
(
source_
name
)
key
=
input
(
'Press any key to continue, press c to exit: '
,
's'
);
if
key
==
'c'
...
...
@@ -37,3 +39,10 @@ while(true)
end
end
% %To get the current position:
% position = sendPosition.NavigationState().NavigationState.position;
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment