金曜日, 1月 12, 2007

designing interactions

designing interactions
必読マストバイ。jamesが関わったsonyの携帯電話のプロジェクトも紹介されてる。block jamもあるな。英語だから読むの大変なんだけど今こそ読むべき。そしてあと一年の学生生活を超有意義にすべき。

冒頭でlanguages of interaction designというのがあって、カテゴリーを1-d,2-d,3-d,4-dに分けてる。1-dは詩や言葉、2-dはアイコンやタイポグラフィー、3-dはハンドルがついていれば人はそこをつかむ、とかプロダクトデザインなどにおける彫刻的な形態。4-dが音や映像、アニメーション。例としてAppleコンピュータで使用された、フォルダのデータサイズによって移動したときの音が変わる、というsoundfinderが紹介されてる。

iamasの授業で参加してるadvanced media schoolプロジェクトの場合は空間をpersonal, public, village, ad hoc、情報のコンテンツの解像度をknow, view, touch, manipulateっていう風に分けて考えてる。

いずれにせよ領域横断的で幅広い内容を取り扱わなくてはならない。最近やっとiamasみたいな場所が必要な意味が理解できた気がする。原始的な生活をテレビかなんかで観て、「あんな生活よくできるよなー」みたいに考えてる人は自分もまた誰かにそう思われてると思った方がいいかな。今のままで十分と思ったらそこで止まる。別に悪いことではないんだけど。

火曜日, 1月 02, 2007

num2snd(python)

あけましておめでとうございます。初詣で「プログラミングができますように」って祈ったらわかりました。pythonでwaveファイルを書き出します。参考にしたのはこことその中でも紹介されてる千葉大のppt。違うところはprepare_list(n)関数のところ。元々はarrayオブジェクトを使っていたんだけど、どうやら今のマシン(ハードディスクがクラッシュしたので友達のを借りてる)だとバージョンが2.3.5で2.4とかとは挙動が異なるみたい。のせいなのか実行できなかったので、単純にサンプリング周波数と秒数分の配列を作ってみました。その方法はここで。あとはほぼ同じ。
max/mspでpeek~使ってインデックスと数値を与えて音を生成したように、data[i]にひたすら数値を入れてあげれば音が出る訳だ...こういうのってやっぱその道の人からすれば当然で別に面白くも何ともないことなのでしょうか。


import wave, math
SAMPFREQ = 44100
LENGTH = 3

def wave_init(fileName, sampFreq):
file = wave.open(fileName, 'w')
file.setnchannels(1)
file.setsampwidth(2)
file.setframerate(sampFreq)
file.setcomptype('NONE', 'not compressed')
return file

def prepare_list(n):
data = range(n)
return data

def wave_write(out, samples):
out.writeframesraw(samples)
out.close()

def sin_wave(fileName, freq):
out = wave_init(fileName, SAMPFREQ)
samples = prepare_list(SAMPFREQ * LENGTH)
a = math.pi * 2.0 * float(freq) / float(SAMPFREQ)
for i in range(SAMPFREQ * LENGTH):
ft = int(math.sin(a * float(i)) * 30000.0)
samples[i] = ft
wave_write(out, samples)

sin_wave('newyear.wav', 2007)


ちなみにpythonで音を作るならpysndobj, pyaudioあたりが要注目です。あと、pdのエクスターナル書いたり。

日曜日, 12月 31, 2006

num2snd(max/msp)

数値が音になる、ということが僕は未だに興味深いのですが、わざわざmax/mspで実装してみました。peek~っていうオブジェクトにインデックスと数値を送ることでbuffer~にデータを入れています。サンプルでは1サンプルずつ数値を入力するものと、自動的にサインウェーブとランダムノイズを作るものがあります。バッファに希望の長さをミリセコンドで指定すればサンプル数に変換されます。その後またサンプル数を手動で変化させてみても面白いです。
作成されたバッファテーブルはgroove~オブジェクトで再生します。この再生位置や速度を変えることでもかなり音響が変化します。サイン波の合成から音を作るのではなく、バッファテーブルに直接データを書き込むことで音を作る手法で、またひとつ下のレイヤーに降りた、という感じ。他の言語でもやってみるつもり。

max v2;
#N vpatcher 633 107 1290 670;
#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P comment 27 167 65 196617 manual input;
#N vpatcher 10 59 610 459;
#P inlet 217 70 15 0;
#P outlet 161 167 15 0;
#P inlet 161 71 15 0;
#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P newex 161 140 51 196617 pack 0 0.;
#P newex 161 98 29 196617 t b f;
#N counter;
#X flags 0 0;
#P newobj 161 119 66 196617 counter;
#P connect 3 0 1 0;
#P connect 1 0 0 0;
#P connect 0 0 2 0;
#P connect 2 0 4 0;
#P connect 1 1 2 1;
#P connect 5 0 0 4;
#P pop;
#P newobj 27 207 49 196617 p manual;
#P flonum 27 186 44 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P message 34 105 33 196617 clear;
#P comment 111 167 56 196617 make noise;
#P comment 240 167 49 196617 make sine;
#P comment 170 167 65 196617 random value;
#P comment 233 107 42 196617 samples;
#P comment 371 68 36 196617 vol;
#P button 242 185 15 0;
#P comment 516 70 47 196617 select all;
#P message 513 85 51 196617 0 -1 0 -1;
#P flonum 218 127 45 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P message 398 227 43 196617 ¥$1 100;
#P newex 363 227 32 196617 line~;
#P flonum 141 185 45 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#N vpatcher 20 74 620 474;
#P inlet 249 118 15 0;
#P window setfont "Sans Serif" 9.;
#P window linecount 0;
#P newex 249 228 51 196617 pack 0 0.;
#P outlet 249 253 14 0;
#P newex 249 138 40 196617 uzi;
#P newex 333 139 27 196617 t f f;
#P newex 350 161 27 196617 / 2.;
#P inlet 333 117 15 0;
#P inlet 279 118 15 0;
#P window linecount 1;
#P newex 279 202 27 196617 - 1.;
#P newex 279 182 34 196617 / 50.;
#P newex 279 161 64 196617 random 100;
#P connect 10 0 7 0;
#P connect 7 2 9 0;
#P connect 9 0 8 0;
#P connect 3 0 7 1;
#P connect 7 0 0 0;
#P connect 0 0 1 0;
#P connect 1 0 2 0;
#P connect 2 0 9 1;
#P connect 5 0 1 1;
#P connect 4 0 6 0;
#P connect 6 0 0 1;
#P connect 6 1 5 0;
#P pop;
#P newobj 112 205 74 196617 p randomnoise;
#N vpatcher 84 195 684 595;
#P window setfont "Sans Serif" 9.;
#P window linecount 0;
#P newex 289 124 27 196617 t f f;
#P newex 289 80 27 196617 t f f;
#P window linecount 1;
#P newex 265 175 51 196617 pack 0 0.;
#P outlet 265 209 15 0;
#P inlet 259 60 15 0;
#P newex 259 102 40 196617 uzi;
#P newex 306 149 212 196617 expr (sin(($f1 / $f2 ) * (2. * 3.1415926)));
#P inlet 289 60 15 0;
#P connect 3 0 2 0;
#P connect 7 0 5 0;
#P connect 5 0 4 0;
#P connect 0 0 6 0;
#P connect 6 0 2 1;
#P connect 2 2 7 0;
#P connect 7 1 1 0;
#P connect 1 0 5 1;
#P connect 6 1 1 1;
#P pop;
#P newobj 242 205 60 196617 p sinewave;
#P message 111 105 42 196617 size ¥$1;
#P newex 162 105 66 196617 mstosamps~;
#P flonum 371 85 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P toggle 495 85 15 0;
#P message 495 206 43 196617 loop ¥$1;
#P message 464 85 29 196617 stop;
#P message 410 85 51 196617 startloop;
#P message 257 85 66 196617 set num2snd;
#P flonum 325 85 42 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P user waveform~ 325 106 200 74 3 9;
#W mode select;
#W mouseoutput continuous;
#W unit ms;
#W grid 1000.;
#W ticks 0;
#W labels 1;
#W vlabels 0;
#W vticks 1;
#W bpm 120. 4.;
#W frgb 33 0 0;
#W brgb 60 178 173;
#W rgb2 0 95 255;
#W rgb3 0 0 0;
#W rgb4 0 0 0;
#W rgb5 190 137 255;
#W rgb6 100 100 100;
#W rgb7 100 100 100;
#P message 71 105 35 196617 write;
#P newex 325 185 29 196617 sig~;
#P newex 325 227 35 196617 *~ 1.;
#P newex 325 206 89 196617 groove~ num2snd;
#P button 112 185 15 0;
#P flonum 112 251 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P number 74 233 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P user ezdac~ 325 249 369 282 0;
#P button 111 67 15 0;
#P newex 111 85 27 196617 i;
#P number 128 67 51 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 71 126 86 196617 buffer~ num2snd;
#P newex 112 230 78 196617 peek~ num2snd;
#P comment 325 68 35 196617 speed;
#P comment 128 50 76 196617 set length (ms);
#P connect 40 0 41 0;
#P connect 30 0 41 1;
#P connect 14 0 3 0;
#P connect 24 0 3 0;
#P connect 39 0 3 0;
#P connect 6 0 5 0;
#P connect 5 0 24 0;
#P connect 10 0 26 0;
#P connect 41 0 2 0;
#P connect 8 0 2 0;
#P connect 26 0 2 0;
#P connect 25 0 2 0;
#P connect 2 0 9 0;
#P connect 4 0 5 1;
#P connect 30 0 26 1;
#P connect 5 0 23 0;
#P connect 27 0 26 2;
#P connect 23 1 30 0;
#P connect 33 0 25 0;
#P connect 30 0 25 1;
#P connect 17 0 15 0;
#P connect 16 0 13 0;
#P connect 20 0 11 0;
#P connect 19 0 11 0;
#P connect 18 0 11 0;
#P connect 13 0 11 0;
#P connect 11 0 12 0;
#P connect 12 0 7 0;
#P connect 28 0 12 1;
#P connect 12 0 7 1;
#P connect 29 0 28 0;
#P connect 15 2 11 1;
#P connect 22 0 29 0;
#P connect 15 3 11 2;
#P connect 21 0 20 0;
#P connect 31 0 15 4;
#P pop;