Skip to content

Commit

Permalink
Merge pull request #16 from jyrkialakuijala/main
Browse files Browse the repository at this point in the history
lifting the phase information into spatialization
  • Loading branch information
jyrkialakuijala authored Feb 26, 2024
2 parents e2b21f5 + ec497a5 commit ff42f1d
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
4 changes: 2 additions & 2 deletions scripts/upmix.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def run(str):
print("playing", file)
run('cp "' + file + '" /tmp/input.wav')

run("sox /tmp/input.wav -b 24 /tmp/down-dry.wav gain -10 rate 48k trim 0 80")
run("sox /tmp/input.wav -b 24 /tmp/down-dry.wav gain -10 rate 48k trim 0 8")

run("./build/revolve /tmp/down-dry.wav /tmp/16speakers.wav")

Expand All @@ -51,7 +51,7 @@ def run(str):

run("./build/driver_model /tmp/down3-20.wav /tmp/down3-mod.wav")

run("sox /tmp/down3-mod.wav -b 24 /tmp/down3-norm.wav treble -3 10000 norm -22");
run("sox /tmp/down3-mod.wav -b 24 /tmp/down3-norm.wav treble -3 10000 norm -32");

run("amixer --card 3 cset numid=3,iface=MIXER,name='UMC1820 Output Playback Volume' 127,127,127,127,127,127,127,127,122,122,122,122,122,122,122,122")
run("amixer --card 3 cset numid=1,iface=MIXER,name='UMC1820 Output Playback Switch' on,on,on,on,on,on,on,on,on,on,on,on,on,on,on,on")
Expand Down
25 changes: 22 additions & 3 deletions speaker_experiments/revolve.cc
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,19 @@ struct Rotator {
rot[2] += windowM1 * rot[1];
rot[3] += windowM1 * rot[2];
}
void GetTriplet(std::complex<double> right_rot,
std::complex<double> left_rot,
double &right,
double &center,
double &left) {
auto ave = 0.5 * (right_rot + left_rot);
center = rot[0].real() * ave.real() + rot[0].imag() * ave.imag();

right_rot -= ave;
left_rot -= ave;
right = rot[0].real() * right_rot.real() + rot[0].imag() * right_rot.imag();
left = rot[0].real() * left_rot.real() + rot[0].imag() * left_rot.imag();
}
double GetSample() const {
return rot[0].real() * rot[3].real() + rot[0].imag() * rot[3].imag();
}
Expand Down Expand Up @@ -184,12 +197,18 @@ void Process(
assumed_distance_to_line * assumed_distance_to_line);
float dist_ratio = distance_to_virtual * (1.0f / assumed_distance_to_line);
float index = static_cast<float>(subspeaker_index);
const double sample = .5f * (rot_left[rot].GetSample() +
rot_right[rot].GetSample());
double right, center, left;
rot_left[rot].GetTriplet(rot_right[rot].rot[3], rot_left[rot].rot[3], right, center, left);
float speaker_offset_left = (2 - 7.5) * 0.1;
float speaker_offset_right = (13 - 7.5) * 0.1;
for (int kk = 0; kk < 16; ++kk) {
float speaker_offset = (kk - 7.5) * 0.1;
output[i * output_channels + kk] +=
AngleEffect(speaker_offset + distance_from_center, assumed_distance_to_line) * sample;
AngleEffect(speaker_offset + distance_from_center, assumed_distance_to_line) * center;
output[i * output_channels + kk] +=
AngleEffect(speaker_offset - speaker_offset_right, assumed_distance_to_line) * right;
output[i * output_channels + kk] +=
AngleEffect(speaker_offset - speaker_offset_left, assumed_distance_to_line) * left;
}
}
}
Expand Down

0 comments on commit ff42f1d

Please sign in to comment.