Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor changes to get fricatives to show up #4

Open
wants to merge 4 commits into
base: gh-pages
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cpp/car.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ struct CARParams {
first_pole_theta = 0.85 * M_PI;
zero_ratio = sqrt(2.0);
high_f_damping_compression = 0.5;
erb_per_step = 0.5;
erb_per_step = 0.35;
min_pole_hz = 30;
erb_break_freq = 165.3; // The Greenwood map's break frequency in Hertz.
// Glassberg and Moore's high-cf ratio.
Expand Down
47 changes: 25 additions & 22 deletions cpp/carfac.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,13 @@
console.log("sampleRate = " + context.sampleRate);
console.assert(context.sampleRate == 44100);

// Use as a (not very good) anti-aliasing filter.
antiAliasFilterNode = context.createBiquadFilter();
antiAliasFilterNode.type = "lowpass";
antiAliasFilterNode.frequency = 8000; // Hertz.
antiAliasFilterNode.Q = 1;

InitInputNodes(context, antiAliasFilterNode);

// Control the input level with a slider.
gainNode = context.createGainNode();
gainNode = context.createGain();
document.getElementById('input_gain').onchange =
function () { gainNode.gain.value = this.value; };
antiAliasFilterNode.connect(gainNode);
function () { gainNode.gain.value = Math.pow(this.value, 3); };

InitInputNodes(context, gainNode);

saiNode = CreateSAINode(context);
gainNode.connect(saiNode);
Expand All @@ -29,25 +23,34 @@
saiNode.connect(context.destination);
}

navigator.getUserMedia = ( navigator.getUserMedia ||
navigator.webkitGetUserMedia ||
navigator.mozGetUserMedia ||
navigator.msGetUserMedia);

function InitInputNodes(context, antiAliasFilterNode) {
var inputNodes = [
context.createMediaElementSource(document.getElementById('test_audio')),
null, // Microphone source, Initialized below.
];
inputNodes[0].connect(antiAliasFilterNode);

navigator.webkitGetUserMedia(
{audio: true},
function(e) {
// Microphone input available.
inputNodes[1] = context.createMediaStreamSource(e);
},
function(e) {
// Microphone input unavailable.
console.log(e);
alert('Error accessing microphone:\n' + e);
});

if (navigator.getUserMedia) {
navigator.getUserMedia(
{audio: true},
function(e) {
// Microphone input available.
inputNodes[1] = context.createMediaStreamSource(e);
},
function(e) {
// Microphone input unavailable.
console.log(e);
alert('Error accessing microphone:\n' + e);
});
} else {
console.log("getUserMedia not supported");
}

// Input selector controls.
function selectInputNode(i) {
inputNodes[1 - i].disconnect();
Expand Down
8 changes: 4 additions & 4 deletions cpp/emscripten_bindings.cc
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ class SAIPlotter {
carfac_output_buffer_.reset(new CARFACOutput(true, false, false, false));

sai_params_.num_channels = carfac_->num_channels();
sai_params_.sai_width = num_samples_per_segment;
sai_params_.input_segment_width = num_samples_per_segment;
sai_params_.trigger_window_width = sai_params_.input_segment_width + 1;
sai_params_.sai_width = num_samples_per_segment / 2;
sai_params_.input_segment_width = num_samples_per_segment / 2;
sai_params_.trigger_window_width = sai_params_.input_segment_width * 2 + 1;
// Half of the SAI should come from the future.
sai_params_.future_lags = sai_params_.sai_width / 2;
sai_params_.future_lags = sai_params_.sai_width;
sai_params_.num_triggers_per_frame = 2;
sai_.reset(new SAI(sai_params_));

Expand Down