前提
ProcessingでMac内蔵マイクに声を入れると音に反応して線香花火が大きくなるサンプルコードを実行しましたが、エラーが出てしまい、検索したところ、完全に該当したものが見つからず、困っています。
サンプルコードはこちらです
http://www.joshibi.net/prof/ryodebuchi/Source/sample24/applet/sample24.html
実現したいこと
Mac内蔵マイクから正常に音を認識できる状態にしたいです。
発生している問題・エラーメッセージ
2022-11-05 16:39:37.855 java[7459:7545439] _TIPropertyValueIsValid called with 4 on nil context! 2022-11-05 16:39:37.855 java[7459:7545439] imkxpc_getApplicationProperty:reply: called with incorrect property value 4, bailing. 2022-11-05 16:39:37.855 java[7459:7545439] Text input context does not respond to _valueForTIProperty: 2022-11-05 16:39:37.856 java[7459:7545439] _TIPropertyValueIsValid called with 4 on nil context! 2022-11-05 16:39:37.856 java[7459:7545439] imkxpc_getApplicationProperty:reply: called with incorrect property value 4, bailing. 2022-11-05 16:39:37.856 java[7459:7545439] Text input context does not respond to _valueForTIProperty: ==== JavaSound Minim Error ==== ==== Unable to return a TargetDataLine: unsupported format - PCM_SIGNED 44100.0 Hz, 16 bit, stereo, 4 bytes/frame, little-endian === Minim Error === === Minim.getLineIn: attempt failed, could not secure an AudioInput. NullPointerException
該当のソースコード
Java
1//線香花火プログラミング 2import ddf.minim.*; 3Minim minim; 4AudioInput in; 5 6void setup() 7{ 8 size (500, 500);//フルスクリーン 9 colorMode(RGB, 256, 256, 256, 256);//カラーモード指定 10 11 minim = new Minim(this); 12 minim.debugOn(); 13 in = minim.getLineIn(Minim.STEREO, 512); 14} 15 16//変数宣言 17int x0, y0, x1, y1; 18int x2, y2, x3, y3; 19 20void draw() 21{ 22 background(0);//背景 23 smooth();//滑らかに 24 fill(250, 100, 0, 50);//塗りつぶし 25 26 x0 = x1 = 0; 27 y0 = y1 = 0; 28 x2 = x3 = 0; 29 y2 = y3 = 0; 30 31 stroke(150, 150, 0, 100);//線の色 32 strokeWeight(5);//線の太さ 33 line(width / 2, height / 20, width / 2, height / 2);//線香花火の芯 34 35 //線香花火の火花 36 stroke(250, 100, 0, 50);//線の色 37 strokeWeight(1);//線の太さ 38 for(int i = 0; i < in.bufferSize() - 1; i += 5)//間隔 39 { 40 float r1 = in.left.get(i) * 150 + 5;//反応後のサイズ+半径 41 x1 = x0; 42 y1 = y0; 43 x0 += -r1 / 2 + random(r1); 44 y0 += -r1 / 2 + random(r1); 45 line(x0 + width / 2, y0 + height / 2, x1 + width / 2, y1 + height / 2);//座標 46 float r2 = in.right.get(i) * 200 + 10;//反応後のサイズ+半径 47 x3 = x2; 48 y3 = y2; 49 x2 += -r2 / 2 + random(r2); 50 y2 += -r2 / 2 + random(r2); 51 line(x2 + width / 2, y2 + height / 2, x3 + width / 2, y3 + height / 2);//座標 52 float r3 = in.right.get(i) * 15 + 10;//反応後のサイズ+半径 53 ellipse(width / 2,height / 2, r3, r3); //線香花火の玉 54 } 55} 56 57//停止 58void stop() 59{ 60 in.close(); 61 minim.stop(); 62 super.stop(); 63}
試したこと
ぬるぽがエラーで出ているので、マイクから音声の入力がされないことが原因なのでしょうか
エラーコードで検索したところ、おそらくOSのバージョンが関係しているのかもしれません。
https://github.com/ddf/Minim/issues/75
このサイトに書いてあることを完全に理解できたわけではないのですが、AudioInputをAudioPlayerに置き換えてみましたが、置き換えるだけでは動かないのかin = minim.getLineIn(Minim.STEREO, 512);でエラーが出てしまいました。
エラーのここがよくわかりませんでした、、
Unable to return a TargetDataLine: unsupported format - PCM_SIGNED 44100.0 Hz, 16 bit, stereo, 4 bytes/frame, little-endian
Hzなど形式がステレオと合っていないということでしょうか
補足情報(FW/ツールのバージョンなど)
ここにより詳細な情報を記載してください。
回答1件
あなたの回答
tips
プレビュー