Author Archives: ykang1@andrew.cmu.edu

Project 2 Sound Spatialization

For project 2 I wanted to take advantage of the Media Lab’s 8-channel sound system to create an immersive experience for a listener. Using the HOA Library, I generate lissajous patterns in sonic space as well as allow a user to control the exact placement of one of the three sounds.

In order to emphasize the movement of the sounds, I also have uplighting for the loudspeakers, where each sound corresponds to either red, green, or blue and the moving average amplitude of a signal coming out of a speaker dictates the color values for the lights.

The sounds that are played include sounds made from granular synthesis using parameters based on an accelerometer sent through a Raspberry Pi as well as other effects applied to audio files controlled by a Seaboard (done by Ramin Akhavijou and Rob Keller).

This Google Drive folder includes all of the Max Patches for our project.
https://drive.google.com/open?id=1WZH1nr-ARBmZOF9gPrks3_Oh1Q5mJTS8
The top-level patch that incorporates everything with a (somewhat organized) presentation view is main.maxpat. Most of my work (aside from putting together main.maxpat) is in ambisonics.maxpat, which in turn has several subpatches and sub-subpatches and so on.
ambisonics.maxpat is what receives sounds, sound position coordinates, and outputs data to speakers and lights. poly voicecontrol is where the positioning of an individual sound is handled. placement.maxpat calculates the position for a sound (using coord.maxpat) and spatialize.maxpat contains calls to the HOA Library to calculate the signals that should come out of each speaker channel. These are sent to poly light to calculate the light channel value and write it into the appropriate cell of a global matrix. The global matrix is accessed in ambisonics.maxpat to the lights.

 

Here’s a rough video of our project in action

Project 1 – Speech Analysis

For Project 1 I wanted to do something similar to the speaking piano on YouTube by deconstructing and reconstructing speech. In particular, I thought it would be interesting to deconstruct speech in different languages since different languages just sound so fundamentally different. I found a Max object that would do most of the technical work for this and went ahead and tried it out on different vowel sounds and audio clips of singing/speech, using different types of waves for the reconstruction (sine, triangle, square, sawtooth).

Then I loaded them all up in Audacity, time stretched some of them, and pieced together a short clip that includes some of the outputted audio:

Audio Player

My goal here wasn’t to reconstruct the speech into something comprehensible, but rather to explore the sinusoidal makeup of speech.

 

Main patch:

<pre><code>
----------begin_max5_patcher----------
1068.3oc2X0sipaCD9Z3oHJWVQShiyOPupU87.Toi5UUUHShI3kD6TaGXQGc
1m85eR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jyuRqwn8NwNRNR
Oq6stm0u3j4kf58kCG6uDPnouNXYxzP+cYgtwRpiI8a+MPLGIs7qCUBVCOqC
ccbauNhoatZ7b0P1uNQ64xZGfchx2bcLVOo6ENNOE7fdpyHC5onqONLdNle6
poo20f255fGK9t5CC0i20SNpCGSVU246g7T5X.Y3jj+F7NtIeHOAGSvaJfT3
XpKfShmhGaBwiRnYd2164dxRZipqOf4hVsMdQ0I6IlonHcg4QB09Hz7HGefz
ou4G+xEwU8cjplNMbaajmWl3Z2JSUdQaHsE2JO+04+K.XHOkp
-----------end_max5_patcher-----------
</code></pre>

 

Child Patch 1:

<pre><code>
----------begin_max5_patcher----------
448.3oc2V11ZBCCDG+0seJB800RZ5y6qxXLp0vLhMQRScJhe22kDiS25r5PF
CKXj65k6+86RNzc9dASEancAnmPOi771464Yboc3cv1KnsdSyx5NSXAb56ho
KBBsuRQ2nLtkzFAuSI6aTLAex7ZYqfyZhf8tpV4BmMyDLjfI4Nevqaly3u8J
jBksRpJhhqfmhPDIqHBGhhKw5uHjHL5kCarSscI0jOWp38sL9RpxTowe5Tzq
bdwZm6880Kg+wHmcAjKShRwvCQCY1CCxoW.47pnL8obIvZUxCCxIW.4rrnBM
xU.q4jGFjiu.xoVLSR+2RKjVJBihQDTB53EVqXpsqnVNfpafOGo3zK.3QaGU
l1PY4s1LxGrYj+KZFlb9irtj0oFjMxnnYWSvt0qEM7fn4N8aDssTt5rsy3yn
FDiOgeibP8y+5upYJXs+yaJchdYiCa2oGbWvU0yncJFuVOHbZPPL.YC12uIg
HiHT58RnjQDJ6dIT5HBkeuDBOhPw2AgHWgNth4aWBqWsZMU1cHZiFvL3BgTa
VDZLYbqYhwTRWybwmY7TKgoLELh0KsyNaJs+wofVwLpj2yNL..Ju2+C.oeFR
SA
-----------end_max5_patcher-----------
</code></pre>

 

Child Patch 2:

<pre><code>
----------begin_max5_patcher----------
565.3oc0V01aaCBD9y1+JrP6SSdUFSdwY+UllpH1zTZsAK.2kpple6CNhSaV
bBNsVSaRQDy4i64ddN3vuDGgVK2xznjum7ijnnWhih.SNCQ6mGgZnaKqoZvM
DWTyLnT+ajcF6LyysLeHPnjet+U7Jvc45G9Fo28Vpo7dtXysJVowuhBxMYoI
jbXLqe7PTzlmqgXi5ignqARAHaxdynOU.q38VKkMMLg4nkyEULfdX27WiicC
oij6B1ur7oOTF1Ver0LQ0tj6opFofWpQmp.3vJ.Yt6ObFnD44iWCvCpAYe.5
0vzZ5F1I76KXadcy0UysD4BbFu.CrcEv1YytVNmObce5Jo0bAaWxEHsluQPq
QoIn0TwlyHAYgkf7bntOOaZjf7oSB95tPjeHRuJ7g87kE.k+2qp6xzOFqmGj
0860u5BMYxX8c0RaPN+43KsYdYwHNNOa76kuSpZnvxWbHtJZCyvT2xDz0d2y
FeCu7+xBBIbO8+6ziybrnSzRKez1Mz+6r5kUNsTH8jGFT9xCJeKA0qX0zbgH
4c5ADInG+e7oOPt3rerHokcpxdV1W7SdKgpXZCWPMbo3cN4ZJ3bZvBwXQpOH
WFIxTfDYDHgm.fbsRBCj66G9zP41kkfC.Ue974QJDoHSg7MlxDYJDuCkf.Ep
rIAqrwtOGeDT9ixz11mXJ8duATrc1dPpbSWlBS4B+T39T6U8Ow68eNXgprsg
L1dPcJeyksEKP9kJqXJQGe+8tVjeM92.4.c.1B
-----------end_max5_patcher-----------
</code></pre>

Assignment 4 – audio visualization discs

I found the mesh distortion technique pretty interesting but I was overall unsatisfied with how… messy it looked. I wanted something a little more coherent so I tried something a little different: distorting several copies of the same object. I chose to use “discs” (really flat cylinders) stacked on top of each other. I scaled them evenly in two directions so they’d stay circular but kept their flatness the same.

Here is a video: (I added the audio separately from the video, so it might not be perfectly in sync) ((also oops I used copyrighted music, hopefully this stays on YouTube))

I will admit I would have liked to figure out a way to make the discs themselves look nicer but we can just enjoy some Moiré patterns instead 🙂

Here is my parent patch:

<pre><code>
----------begin_max5_patcher----------
2041.3oc0ZszaiaqEdcxuBBso.Edb3C8rqBJ5haWL.cQ6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oQ6eQ
esVZOezSH8nOCR98y400+snQ20ZmMfHctW4bySl3tTV4uzEFQPi3uk8s2kWj
.dCDGiABhwF3qM5hmR8IWwc3wlpVY2xU.5ttKJjChgXSxLdz1SnUpJktlm2c
1M.Ty4skl8IBQov9e2hKd19CgmjxHgzI1RYowLWozPBklLY2S1Fr2CgIw3rr
ItRjzHhqDlwhB2+grg44dv6jUVRSrSpF19wtOwrEykkkaL1tY2oOlqfEMP.1
a+uz4fwFMCSxhscMCmkhC8kfpH6Yotmhr4L7S1+iCZGsu6SioIgQNVJAGkl5
KkFxNr6gPB8gNRcwn1UacipV0zq0fQV1l1CG4XCx52wvK.7DydnLKIIhj0Mb
gKyhXwr8ox4pJSuJAD0eVUwyUahPcRmGSCXtCixMvkK39AwtdXaUcqnXRDNh
h4Co3344GJ3.4BNyqxnzPeIFFa0f6N5OtVEmQbSnoXLk34df4iSGPqRRSScp
ZZZJoSNDQXGLe8ASpZmwyxRB6KkQFVzRXIXmWZJMIl4oPfXnYeeEsfACYtwb
RZTThuDkRnuUJW3Y92q+edMfVZA
-----------end_max5_patcher-----------
</code></pre>
view raw discs.maxpat hosted with ❤ by GitHub

Here is my child patch:

<pre><code>
----------begin_max5_patcher----------
676.3oc2WssiaBCD8YxWgEuVZJ1lao+JUqVQHNoNkXi.msY0pMe60WH61sxw
wTfJk9RHXFliOm4BieYQP3Z9IRWH3qfuABBdYQPfdI0BA82GDdn7TUcYm1rP
1wCqIsgQlG0TJp9Nks6wVRkv3FT1x3H.LAotjFq9EI+O3g9WgtQ6G958eFFe
wORuRY0DgFC3aNus7.QPZejvJWWSTOK98WfeTb4MP8q1Id1XV3EGaLR7bCwr
6jO.DttjsKD7fxhWWrP8Sjurm7S4F+hyEjSZRGtmJV1v+A4Lfx1PqHc.HH1g
FgiST5BFpkGHLykJUXUjPVEB3.DhoT.5n6NCfNX7JzxTIgSzDNA6hu4NSJ9q
4qbKxJqmovdWUYsNpibnAv7U5ndtoBA5TERuCh5V3uqb.XZtl+Iwdv+j6.9+
I247Pbglgo53MN0EcylG5NCI8e47sSwg4PMYWoJ5uZ2+U+mvYSX1ONWb+vYm
8xxvJZtpvCJmOOTlxDSJe2tUPYa4thzlYZxzcwJvNIMd.eDKYXjNx1kYtsd7
sy+eaXFms0w2As0qJaE7FdsGE8nXc+tLmi4hF.mQCtlOZVp90UCd84MyvbvX
nyI8GP4.dDRvUDC8VJrlx9yy5nokZ8OpPc7isUW.oelTv6DaCoSpNkBJm8a1
jZrwZLvWbx7.mjOXCuci73XpSFM6.isCLbT.i7.3rIPYUSabSfTaF3XApvSf
FMi7IoTSa3Tms3GzE1gF9O.5X6opnwAM9CD5JPmOEgVoOP2.nh4nZzWfm9LJ
O.N0NvnYG3D6.imcfw1ANYz.C8oswTjE6UShXKertro4IRaWu0ZLjCtrmqEf
7H8sTl4V8DCgsjmnWrOUuRYqblEgbfkislAINUXNmc3AtTJYGo8ULRjecwu.
3bAx9A
-----------end_max5_patcher-----------
</code></pre>

Assignment 3 (Yijin Kang)

Original Recordings/Sounds

My two impulse responses were recorded in a racquetball court and in the locker room showers in the UC. I had a friend pop the balloon from the corner of the room and I pointed the Zoom recorder toward the center of the room. The racquetball court’s impulse response had a much longer reverb tail but the locker room showers produced a much deeper ring, which I found interesting.

Racquetball Court:

Audio Player

 

Locker room shower:

Audio Player

 

My two non-IR recordings were water from a shower hitting a shower curtain and a recording from freesound.org of glass breaking. For the water recording, I pushed the shower curtain in toward the water stream and recorded it from outside the shower.

Water:

Audio Player

 

Glass:

Audio Player

 

As my source sound, I used the theme from Phantom of the Opera:

Convolution Results

Racquetball Court:

Audio Player

 

Locker room shower:

Audio Player

The Racquetball Court reverb muddles the voices and sounds a bit “thin” compared to the reverb with the locker room shower IR.

Water:

Audio Player

I thought the ending of the piece sounded interesting too, so I threw that in there.

Glass:

Audio Player

The instrumental in the second verse sounded pretty interesting, so I kept that in here.

Other interesting discovery 1

While looking for interesting sounds, I also found that this recording of a crackling fire from freesound produces interesting results with speaking voices and single instruments:

Audio Player

 

Convolved with Alvin Lucier:

Audio Player

Sounds pretty creepy!

 

Convolved with the beginning of Liszt’s La Campanella:

Audio Player

(original audio source: https://www.youtube.com/watch?v=H1Dvg2MxQn8)
This piece does get pretty crazy toward the end, but never this crazy

Other interesting discovery 2

I thought that the convolution with the glass breaking would produce interesting results on other sounds, so I tried convolving that with speaking voice, piano, and percussion.

Convolved with Alvin Lucier:

Audio Player

Sibilants like s’s seem much more pronounced.

Convolved with piano:

Audio Player

The high notes really stand out here.

Convolved with castanets (from https://freesound.org/people/InspectorJ/sounds/411457/)

Audio Player

The castanets almost sound…metallic?

Assignment 2 – Delay with Pitch Shift, Ring Modulation

I started with a simple feedback with delay on audio signals and then tried to find other effects to use on the delayed signal (like the pitch shifted example we saw in class). I tried things like filters and down-sampling, but these weren’t quite as interesting since they’re, for the most part, idempotent, so the 2nd, 3rd, 4th, etc echos wouldn’t sound too different from the first. In the end, I went with pitch shifting + ring modulation.

Here’s an example on a clip from Spongebob (might have to turn volume up a little):

And here’s the patch:

<pre><code>
----------begin_max5_patcher----------
1381.3oc2Ys0biZCE9YmeEL7TaGWO5NPeZ6K8OwNcxHikczV.QAwljcmM+1q
t.D6DaB1f2jo9A.c8b99NGczQxe+lEgqUOHpCC9ifOGrXw2uYwBWU1JVzVdQ
XN+gzLdsqagEM4qEUgK8MUxq34Bsn5VQAeclv1EPaa05G8UD10ayXkEYBsal
fOWopQ2UKpsVeU5GKEdkyLGAgq4E6BC96dYqSuSVr61JQp12KLMYEXY.hAru
ntmHzJP+XjabJjZ8W9cBLzV2Ot4F6ik+e.9zX3J5x.Lg71vGGeIvealxnvyH
72ppx4N0mcEHDVDzxA3X7HHD1kPHop7bQgtCiZwCNQGVYTjfb0llLtVpJB9k
6k56BtSjUFrsRkGnazpJIOq9W6FZlrPjpZJz6C6KxIBbZBIBwrb.A4nBnmQv
3iyHH5bxHkRi1DTembq1nSgWI.RihbF4nX6K+SKXOJ9vWTD.w8lA+J38aOMR
HgNJ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aiP0Lmlb+Nop1Hpbqqu5RFhGx0
.AZub.x9tFv8SupWWASRWeACbbkkcMXoQKY3ri4wXelgUGcAzNGWvWFiva5o
9iWff39Rys4XTJ6vdsGprDbr+tA2uzOAOZX7X2q4jwjnI9ahh4UVHpuzT8Hh
Fa7xIKIxHjzbrE.DeFaDNMIc9gpdgcERPNGzDp+u+yeOLIzoaWASV0fT28H.
R1S0bklppMR+.3AxwmvGur7qhp51N6DgI27unbqRiVdi+OMvWD6JVI9prq+T
WM7JSN2ZSB2lin6Rj9gXVnenljnqJZjswtLR9G27eUCJzpB
-----------end_max5_patcher-----------
</code></pre>
view raw ts-a2.maxpat hosted with ❤ by GitHub

Assignment 1 – Image Rotation

The other day in a computer science class, I came across a funky-looking function that made my head spin trying to understand it. I wanted to try to emulate that feeling by taking an image of that formula and using Python’s image rotation function to rotate the image 41 degrees at a time. I chose 41 degrees because I wanted something that would not divide 360 degrees evenly. Pretty soon, we start to see the effects of resampling the image at every rotation. We also see the edges of the image rounding out as corners are clipped off at each rotation.

This video shows 30 iterations using the nearest pixel’s value for resampling. (The image didn’t seem to change much more after 30 iterations)

Out of curiosity, I also tried playing with the other two possibilities for resampling. This is what the image looked like after 100 iterations of bilinear resampling (linear interpolation in a 2×2 environment):

And this is what it looked like after 100 iterations of bicubic resampling (cubic spline interpolation in a 4×4 environment):

My code:

import sys
from PIL import Image
# https://pillow.readthedocs.io/en/latest/reference/Image.html#PIL.Image.Image.rotate
delta = 41
def func(iterations, resample_arg):
if resample_arg == "nearest":
resample = Image.NEAREST
if resample_arg == "bilinear":
resample = Image.BILINEAR
if resample_arg == "bicubic":
resample = Image.BICUBIC
for i in range(0, iterations):
if i == 0:
img = Image.open('source.png')
else:
img = Image.open('{}-out{}.png'.format(resample_arg, i-1))
new_img = img.rotate(delta, resample=resample)
new_img_filename = '{}-out{}.png'.format(resample_arg, i)
new_img.save(new_img_filename, 'png')
print("wrote {}".format(new_img_filename))
func(int(sys.argv[1]), sys.argv[2])