Skip to content

Commit

Permalink
Adding further demo files
Browse files Browse the repository at this point in the history
  • Loading branch information
shanqing-cai committed Jan 11, 2014
1 parent ceddfbf commit 24b397a
Show file tree
Hide file tree
Showing 8 changed files with 134 additions and 8 deletions.
15 changes: 15 additions & 0 deletions example_data/focal_fmt_pert.ost
@@ -0,0 +1,15 @@
# Online status tracking (OST) configuration file
rmsSlopeWin = 0.030000

# Main section: Heuristic rules for tracking
n = 8
0 INTENSITY_RISE_HOLD 0.02 0.05 {} # Detect voicing onset during "I"
2 INTENSITY_RATIO_RISE 0.9666 0.0200 {} # Detect the onset of the [s] in "said"
4 INTENSITY_RATIO_FALL_HOLD 0.9666 0.004 {} # Detect the offset of the [s]
6 INTENSITY_RISE_HOLD_POS_SLOPE 0.01 0.020 {} # Detect the onset of [eh] in "said"
8 INTENSITY_FALL 0.01 0.0250 {} # Detect the offset of [eh] in "said"
10 INTENSITY_RISE_HOLD_POS_SLOPE 0.01 0.020 {} # Detect the onset of [ae] in "pap"
12 INTENSITY_FALL 0.01 0.0250 {} # Detect the offset of [ae] in "pap"
14 OST_END NaN NaN {}

n = 0
21 changes: 21 additions & 0 deletions example_data/focal_fmt_pert.pcf
@@ -0,0 +1,21 @@
# Section 1 (Time warping): (ostStat_initial), tBegin, rate1, dur1, durHold, rate2
0

# Section 2: stat pitchShift(st) gainShift(dB) fmtPertAmp fmtPertPhi(rad)
15
0, 0.0, 0, 0, 0
1, 0.0, 0, 0, 0
2, 0.0, 0, 0, 0
3, 0.0, 0, 0, 0
4, 0.0, 0, 0, 0
5, 0.0, 0, 0, 0
6, 0.0, 0, 0, 0
7, 0.0, 0, 0, 0
8, 0.0, 0, 0, 0
9, 0.0, 0, 0, 0
10, 0.0, 0, 0, 0
11, 0.0, 0, 0, 0
12, 0.0, 0, 0.25, -0.7854 # Angle = -pi / 4
# 12, 0.0, 0, 0.25, 2.3562 # Angle = pi / 4 * 3
13, 0.0, 0, 0, 0
14, 0.0, 0, 0, 0
8 changes: 8 additions & 0 deletions example_data/one_state_tracking.ost
@@ -0,0 +1,8 @@
# Online status tracking (OST) configuration file
rmsSlopeWin = 0.030000

# Main section: Heuristic rules for tracking
n = 1
0 OST_END NaN NaN {} # Compulsory ending rule

n = 0
8 changes: 8 additions & 0 deletions example_data/persistent_pitch_pert.pcf
@@ -0,0 +1,8 @@
# Section 1 (Time warping): tBegin, rate1, dur1, durHold, rate2
0

# Section 2: stat pitchShift(st) gainShift(dB) fmtPertAmp fmtPertPhi(rad)
1
0, 2.0, 0, 0, 0


13 changes: 13 additions & 0 deletions example_data/time_warp_demo.pcf
@@ -0,0 +1,13 @@
# Section 1 (Time warping): (ostStat_initial), tBegin, rate1, dur1, durHold, rate2
1
2, 0.1, 0.5, 0.2, 0.1, 2

# Section 2: stat pitchShift(st) gainShift(dB) fmtPertAmp fmtPertPhi(rad)
7
0, 0.0, 0, 0, 0
1, 0.0, 0, 0, 0
2, 0.0, 0, 0, 0 # Onset of voicing
3, 0.0, 0, 0, 0
4, 0.0, 0, 0, 0
5, 0.0, 0, 0, 0
6, 0.0, 0, 0, 0
13 changes: 13 additions & 0 deletions example_data/two_blips.ost
@@ -0,0 +1,13 @@
# Online status tracking (OST) configuration file
rmsSlopeWin = 0.030000

# Main section: Heuristic rules for tracking
n = 6
0 INTENSITY_RISE_HOLD 0.02 0.05 {} # Detect voicing onset
2 ELAPSED_TIME 0.10 NaN {}
3 ELAPSED_TIME 0.20 NaN {} # Pitch shift 1
4 ELAPSED_TIME 0.30 NaN {}
5 ELAPSED_TIME 0.20 NaN {} # Pitch shift 2
6 OST_END NaN NaN {}

n = 0
12 changes: 12 additions & 0 deletions example_data/two_pitch_shifts.pcf
@@ -0,0 +1,12 @@
# Section 1 (Time warping): tBegin, rate1, dur1, durHold, rate2
0

# Section 2: stat pitchShift(st) gainShift(dB) fmtPertAmp fmtPertPhi(rad)
7
0, 0.0, 0, 0, 0
1, 0.0, 0, 0, 0
2, 0.0, 0, 0, 0
3, 2.0, 0, 0, 0
4, 0.0, 0, 0, 0
5, 2.0, 0, 0, 0
6, 0.0, 0, 0, 0
52 changes: 44 additions & 8 deletions mcode/audapterDemo_online.m
Expand Up @@ -9,7 +9,9 @@ function audapterDemo_online(mode, varargin)
defaultGender = 'female';

%% Visualization configuration
ostMult = 500;
gray = [0.5, 0.5, 0.5];
ostMult = 250;
legendFontSize = 8;

%%
Audapter('deviceName', audioInterfaceName);
Expand Down Expand Up @@ -56,6 +58,36 @@ function audapterDemo_online(mode, varargin)
visName = 'Persistent formant shift';

elseif isequal(mode, 'focalFormantShift');
gender = varargin{1};

ostFN = '../example_data/focal_fmt_pert.ost';
pcfFN = '../example_data/focal_fmt_pert.pcf';

check_file(ostFN);
check_file(pcfFN);
Audapter('ost', ostFN, 0);
Audapter('pcf', pcfFN, 0);

params = getAudapterDefaultParams(gender);

params.bShift = 1;
params.bRatioShift = 1;
params.bMelShift = 0;

AudapterIO('init', params);

Audapter('reset');
Audapter('start');
fprintf(1, 'Please say "I said pap again"...');
pause(2);
fprintf(1, '\n');
Audapter('stop');


bVis = 1;
bVisFmts = 1;
bVisOST = 1;
visName = 'Focal formant shift';

elseif isequal(mode, 'persistentPitchShift')
ostFN = '../example_data/one_state_tracking.ost';
Expand Down Expand Up @@ -136,8 +168,9 @@ function audapterDemo_online(mode, varargin)
Audapter('pcf', '', 0);

globalDelay = [0.100, 0.200]; % Unit: s
% globalDelay = [0.200, 0.400]; % Unit: s
gain = [1.0, 1.0];
pitchShiftRatio = 2 .^ ([-2, 4] / 12);
pitchShiftRatio = 2 .^ ([-2, 2] / 12);

params = getAudapterDefaultParams(defaultGender);
frameDur = params.frameLen / params.sr;
Expand Down Expand Up @@ -239,7 +272,7 @@ function audapterDemo_online(mode, varargin)
show_spectrogram(data.signalIn, data.params.sr, 'noFig');

if bVisFmts
plot(tAxis, data.fmts(:, 1 : 2), 'w');
plot(tAxis, data.fmts(:, 1 : 2), 'Color', gray);
end
if bVisOST
plot(tAxis, data.ost_stat * ostMult, 'b-');
Expand All @@ -259,10 +292,12 @@ function audapterDemo_online(mode, varargin)

legendItems = {};
if bVisFmts
plot(tAxis, data.fmts(:, 1 : 2), 'w');
plot(tAxis, data.fmts(:, 1 : 2), 'Color', gray);
plot(tAxis, data.sfmts(:, 1 : 2), 'g');
legendItems{end + 1} = 'Original F1 and f2';
legendItems{end + 1} = 'Shifted F1 and f2';
legendItems{end + 1} = 'Original F1';
legendItems{end + 1} = 'Original F2';
legendItems{end + 1} = 'Shifted F1';
legendItems{end + 1} = 'Shifted F2';
end
if bVisOST
plot(tAxis, data.ost_stat * ostMult, 'b-');
Expand All @@ -278,8 +313,9 @@ function audapterDemo_online(mode, varargin)
sprintf('Output sound: %s', visName), 'FontSize', 12);

if ~isempty(legendItems)
legend(legendItems);
legend(legendItems, 'FontSize', legendFontSize, ...
'Location', 'Southwest');
end
end

return
return

0 comments on commit 24b397a

Please sign in to comment.