Composerだって音楽を奏でたい

Sponsored · Your Podcast. Everywhere. Effortlessly. Share. Educate. Inspire. Entertain. You do you. We'll handle the rest. →

 Composerだって音楽を奏でたい

PHPMatsuri Reboot in Hackone での成果発表LTです

hideki kinjyo PRO

November 07, 2026

Annual Pro sale · Save $30

Have presentations of your own?

Share with private links, password protection, and more control over your work.

Transcript

18 slides
  1. 音の送信 $osc = new UdpOscClient( '127.0.0.1', 9000, ); $osc->send( '/drum/snare',

    [0.8, 0.22], ); • Open Sound Control • という規格(に乗っかった) • 「メッセージ」と 「引数」で構成される
  2. 音の送信 for ($n = 0; $n < $count; $n++, $i++)

    { $t = $i / $sampleRate; $phase += 2 * M_PI * (46 + 170 * exp(-$t / 0.028)) / $sampleRate; $body = sin($phase) * exp(-$t / $decayConstant); $click = self::noise() * exp(-$t / 0.0015) * 0.35; $fade = min(1.0, ($length - 1 - $i) / self::FADE_SAMPLES); $sample = tanh(self::DRIVE * $body + $click) * $fade * $gain; $left[$n] += $sample; $right[$n] += $sample; } 受け 取っ た音 を波 形 デー タに する
  3. 音の再生 • FFIで良い感じにやる foreach ($buffer->samples as $i => $sample) {

    $this->samples[$i] = $sample; } $result = $this ->portAudio->Pa_WriteStream( $this->stream[0], $this->samples, intdiv( count($buffer->samples), $this->format->channels), ); • • PortAudio

More Decks by hideki kinjyo

Other Decks in Programming