Archive for the 'mpSoundKit' Category

2017/12/14 MPSoundEngineでサウンド発生

オープンソースの「MPSoundEngine」(By Matthias Plappert)をFramework化した「mpSoundKit」を呼び出してサウンドを発生させるAppleScriptです。

OS X 10.10以降用にビルドしたフレームワークのバイナリを用意しておきました。興味のある方は自己責任で~/Library/Frameworksフォルダに入れてお試しください。

–> Download Framework Binary

MPSoundEngineはモノラル/ステレオで指定周波数のサインウェーブを発生させるだけのものです。

機能が単純で素朴なので、いろいろやってみたくなる危険な香りがします。64ビットの8コアのコンピュータを使っているのに、なぜか1980年代にタイムスリップして8ビットのコンピュータを使っているかのような錯覚に陥ります。

MMLの解釈・再生プログラムを作り出したら「負け」のような気が、、、

AppleScript名:mpSoundEngineでA=440Hzのモノラルの音を出す
– Created 2017-12-14 by Takaaki Naganoya
– 2017 Piyomaru Software
use AppleScript version “2.4″
use scripting additions
use framework “Foundation”
use framework “mpSoundKit” –https://github.com/matthiasplappert/MPSoundEngine
–http://piyocast.com/as/archives/5030

set engine to current application’s MPMonoSoundEngine’s alloc()’s init()
engine’s channel()’s setFrequency:440.0
engine’s start()
delay 3
engine’s |stop|()

★Click Here to Open This Script 

AppleScript名:mpSoundEngineで440Hzと261Hzの音を出す
– Created 2017-12-14 by Takaaki Naganoya
– 2017 Piyomaru Software
use AppleScript version “2.4″
use scripting additions
use framework “Foundation”
use framework “mpSoundKit” –https://github.com/matthiasplappert/MPSoundEngine
–http://piyocast.com/as/archives/5030

set engine to current application’s MPStereoSoundEngine’s alloc()’s init()
engine’s leftChannel()’s setFrequency:440.0
engine’s rightChannel()’s setFrequency:261.0
engine’s start()
delay 0.5
engine’s |stop|()

★Click Here to Open This Script 

AppleScript名:mpSoundEngineで音階を出す
– Created 2017-12-14 by Takaaki Naganoya
– 2017 Piyomaru Software
use AppleScript version “2.4″
use scripting additions
use framework “Foundation”
use framework “mpSoundKit” –https://github.com/matthiasplappert/MPSoundEngine
–http://piyocast.com/as/archives/5030

property engine : missing value

set engine to current application’s MPMonoSoundEngine’s alloc()’s init()
–https://pages.mtu.edu/~suits/notefreqs.html
set soundList to {261.63, 293.66, 329.63, 349.23, 392.0, 440.0, 493.88, 523.25}

repeat with i in soundList
  makeSound(i) of me
end repeat

engine’s |stop|()

on makeSound(aHz)
  engine’s channel()’s setFrequency:aHz
  
engine’s start()
  
delay 0.1
  
–engine’s |stop|()
end makeSound

★Click Here to Open This Script 

AppleScript名:電話の呼び出し音のような音
– Created 2017-12-14 by Takaaki Naganoya
– 2017 Piyomaru Software
use AppleScript version “2.4″
use scripting additions
use framework “Foundation”
use framework “mpSoundKit” –https://github.com/matthiasplappert/MPSoundEngine
–http://piyocast.com/as/archives/5030

property engine : missing value

set engine to current application’s MPMonoSoundEngine’s alloc()’s init()
–https://pages.mtu.edu/~suits/notefreqs.html
set soundList to {440.0, 466.16}

repeat 10 times
  repeat with i in soundList
    makeSound(i) of me
  end repeat
end repeat

engine’s |stop|()

on makeSound(aHz)
  engine’s channel()’s setFrequency:aHz
  
engine’s start()
  
delay 0.05
  
–engine’s |stop|()
end makeSound

★Click Here to Open This Script 

AppleScript名:音階発生(Stereo)
– Created 2017-12-14 by Takaaki Naganoya
– 2017 Piyomaru Software
use AppleScript version “2.4″
use scripting additions
use framework “Foundation”
use framework “mpSoundKit” –https://github.com/matthiasplappert/MPSoundEngine
–http://piyocast.com/as/archives/5030

property engine : missing value

set engine to current application’s MPStereoSoundEngine’s alloc()’s init()
–https://pages.mtu.edu/~suits/notefreqs.html
set soundList to {261.63, 293.66, 329.63, 349.23, 392.0, 440.0, 493.88, 523.25}
set aLen to length of soundList

repeat with i from 1 to aLen
  makeStereoSound(item i of soundList, item (aLen - i + 1) of soundList) of me
end repeat

engine’s |stop|()

on makeStereoSound(aHz, bHz)
  engine’s leftChannel()’s setFrequency:aHz
  
engine’s rightChannel()’s setFrequency:bHz
  
engine’s start()
  
delay 0.5
end makeStereoSound

★Click Here to Open This Script 

AppleScript名:mpSoundEngineでループ音声発生(サイレン1)
– Created 2017-12-14 by Takaaki Naganoya
– 2017 Piyomaru Software
use AppleScript version “2.4″
use scripting additions
use framework “Foundation”
use framework “mpSoundKit” –https://github.com/matthiasplappert/MPSoundEngine
–http://piyocast.com/as/archives/5030

set engine to current application’s MPMonoSoundEngine’s alloc()’s init()
engine’s start()
repeat with i from 100 to 1000 by 20
  repeat with ii from i to 1000 by 20
    (engine’s channel()’s setFrequency:ii)
    
delay 0.005
  end repeat
end repeat

engine’s |stop|()

★Click Here to Open This Script 

AppleScript名:mpSoundEngineでループ音声発生(サイレン2)
– Created 2017-12-14 by Takaaki Naganoya
– 2017 Piyomaru Software
use AppleScript version “2.4″
use scripting additions
use framework “Foundation”
use framework “mpSoundKit” –https://github.com/matthiasplappert/MPSoundEngine
–http://piyocast.com/as/archives/5030

set engine to current application’s MPMonoSoundEngine’s alloc()’s init()
engine’s start()
repeat with i from 1000 to 100 by -20
  (engine’s channel()’s setFrequency:i)
  
delay 0.01
end repeat

engine’s |stop|()

★Click Here to Open This Script 

AppleScript名:ランダム音発生(昔のSFでコンピュータが演算している風の音)
– Created 2017-12-14 by Takaaki Naganoya
– 2017 Piyomaru Software
use AppleScript version “2.4″
use scripting additions
use framework “Foundation”
use framework “mpSoundKit” –https://github.com/matthiasplappert/MPSoundEngine
–http://piyocast.com/as/archives/5030

set engine to current application’s MPMonoSoundEngine’s alloc()’s init()

engine’s start()

repeat 1000 times
  set aNum to random number from 50 to 4000
  (
engine’s channel()’s setFrequency:aNum)
  
delay 0.02
end repeat

engine’s |stop|()

★Click Here to Open This Script