ADX2情報

「ADX2情報」の編集履歴(バックアップ)一覧はこちら

ADX2情報 - (2013/04/17 (水) 23:53:20) の1つ前との変更点

追加された行は緑色になります。

削除された行は赤色になります。

<p>ADX2 LE情報(<a name="http:__www.facebook.com_groups_adx2userj_files_">facebook ADX2ユーザー助け合い所</a>からコピー)<span style="font-size:smaller;"><br /></span></p> <p><span style="font-size:smaller;">検索にひっかかるようにwikiに</span></p> <div class="mtl fbDocument"> <p><span style="font-size:smaller;"><strong>■効果音を作りたい</strong></span></p> <table width="100%" cellspacing="1" cellpadding="1" border="1"><tbody><tr><td> <p><a target="_blank" href="http://www.slideshare.net/tatmos/adx2le-ggj13/33"><span style="font-size:smaller;">http://www.slideshare.net/tatmos/adx2le-ggj13/33</span></a><span style="font-size:smaller;"><br /> の33ページから「爆発音」「レーザー音」「サイレン音」など作ってみましょう。</span><span style="font-size:smaller;"><br /></span></p> </td> </tr></tbody></table><p><span style="font-size:smaller;"><strong>■初期化手順</strong></span></p> <table width="100%" cellspacing="1" cellpadding="1" border="1"><tbody><tr><td> <p><span style="font-size:smaller;"><strong>CRIメニュー</strong>から<br /> ①<strong>Create CRIWARE Libraly Initializer</strong>初期化オブジェクトをシーン追加<br /> ②<strong>Create CRIWARE Error Handler</strong>エラーハンドラをシーン追加<br /> ③<strong>Open CRI Atom Window ...</strong></span><br /><span style="font-size:smaller;">から</span><br /><span style="font-size:smaller;"><strong>Select Assets Root</strong>で[Atom Craftの出力したAssetsフォルダ]を指定</span><br /><span style="font-size:smaller;"><strong>Update Assets of "CRI Atom Craft"</strong>で更新</span><br /><span style="font-size:smaller;">④Unityを一度バックグラウンドに(デスクトップ表示など)して戻し、</span><br /><span style="font-size:smaller;">CRI Atomウィンドウをクリック</span><span style="font-size:smaller;"><br /></span></p> </td> </tr></tbody></table><p> <span style="font-size:smaller;"><strong>■CriAtomSouceコンポーネントの追加</strong></span></p> <table width="100%" cellspacing="1" cellpadding="1" border="1"><tbody><tr><td><span style="font-size:smaller;">atomSourceSe = gameObject.AddComponent&lt;CriAtomSource&gt; ();</span><br /><span style="font-size:smaller;">atomSourceSe.cueSheet = cueSheetName; //キューシート名指定</span><span style="font-size:smaller;"><br /></span></td> </tr></tbody></table><p>【補足】AtomSouceコンポーネントをスクリプトで作りたい場合の例です。</p> <p><span style="font-size:smaller;"><strong>■再生/停止/ポーズ/ポーズ解除</strong></span></p> <table width="100%" cellspacing="1" cellpadding="1" border="1"><tbody><tr><td> <p><span style="font-size:smaller;">atomSourceSe.Play(4); // キューID指定再生</span><br /><span style="font-size:smaller;">atomSourceSe.Play(“orchehit”); //キュー名指定再生</span><br /><span style="font-size:smaller;">atomSourceSe.Stop();</span><br /><span style="font-size:smaller;">atomSourceSe.Pause(true);</span><br /><span style="font-size:smaller;">atomSourceSe.Pause(false);</span><span style="font-size:smaller;"><br /></span></p> </td> </tr></tbody></table><p><span style="font-size:smaller;"><strong>■Pitch/Volume変更</strong></span></p> <table width="100%" cellspacing="1" cellpadding="1" border="1"><tbody><tr><td><span style="font-size:smaller;">atomSourceSe.pitch = 100; // cent(100で半音)</span><br /><span style="font-size:smaller;">atomSourceSe.volume = 1.0f;   // 1.0で原音と同じ振幅レベル</span></td> </tr></tbody></table><p><span style="font-size:smaller;"><strong>■AISAC変更</strong></span></p> <table width="100%" cellspacing="1" cellpadding="1" border="1"><tbody><tr><td> <p><span style="font-size:smaller;">atomSourceSe.SetAisac(aisac_id,value);//AISACコントロールID指定</span><br /><span style="font-size:smaller;">atomSourceSe.SetAisac(“Any”,value); //AISACコントロール名指定</span><span style="font-size:smaller;"><br /></span></p> </td> </tr></tbody></table><p> <span style="font-size:smaller;"><strong>■カテゴリボリューム変更</strong></span></p> <table width="100%" cellspacing="1" cellpadding="1" border="1"><tbody><tr><td> <p><span style="font-size:smaller;">CriAtom.SetCategoryVolume("BGM",bgmVolume);</span><span style="font-size:smaller;"><br /></span></p> </td> </tr></tbody></table><p> </p> <p><span style="font-size:smaller;"><strong>■バスセンド(リバーブ量変化等)</strong></span></p> <table width="100%" cellspacing="1" cellpadding="1" border="1"><tbody><tr><td> <p><span style="font-size:smaller;">float depth = 1.0f;</span><br /><span style="font-size:smaller;">int busNo = 1; //reverb</span><br /><span style="font-size:smaller;">atomSourceSe.SetBusSendLevelOffset(busNo,depth);</span><span style="font-size:smaller;"><br /></span></p> </td> </tr></tbody></table><p> </p> <p><span style="font-size:smaller;"><strong>■再生時刻の取得</strong></span></p> <table width="100%" cellspacing="1" cellpadding="1" border="1"><tbody><tr><td> <p><span style="font-size:smaller;">GUILayout.Label(atomSourceBgm.time.ToString());</span><span style="font-size:smaller;"><br /></span></p> </td> </tr></tbody></table><p> </p> <p><span style="font-size:smaller;"><strong>■再生状態の取得</strong></span></p> <table width="100%" cellspacing="1" cellpadding="1" border="1"><tbody><tr><td><span style="font-size:smaller;">CriAtomSource.Status status = atomSourceBgm.status;</span><br /><span style="font-size:smaller;">   if ((status == CriAtomSource.Status.Stop) || (status == CriAtomSource.Status.PlayEnd)) {</span>//停止かエンドか<br /><span style="font-size:smaller;">       this.playbackBGM = atomSourceBgm.Play(100);</span><br /><span style="font-size:smaller;"> }</span><span style="font-size:smaller;"><br /></span></td> </tr></tbody></table><p><span style="font-size:smaller;"><strong>■キュー情報一括取得</strong></span></p> <table width="100%" cellspacing="1" cellpadding="1" border="1"><tbody><tr><td> <p><span style="font-size:smaller;">string cueSheetName = “Pinball”;</span><br /><span style="font-size:smaller;">CriAtomExAcb acb = CriAtom.GetAcb (cueSheetName);</span><br /><span style="font-size:smaller;">CriAtomEx.CueInfo[] cueInfoList = acb.GetCueInfoList ();</span><span style="font-size:smaller;"><br /></span></p> </td> </tr></tbody></table><hr /><p><span style="font-size:smaller;"><strong>■再生中のブロックインデックスの取得</strong></span>(ブロック再生)</p> <table width="100%" cellspacing="1" cellpadding="1" border="1"><tbody><tr><td> <p><span style="font-size:smaller;">CriAtomExPlayback playbackBGM;</span><br /><span style="font-size:smaller;">playbackBGM = atomSourceBgm.Play(100);</span><br /><span style="font-size:smaller;">int cur = this.playbackBGM.GetCurrentBlockIndex();</span><span style="font-size:smaller;"><br /></span></p> </td> </tr></tbody></table><p> </p> <p><span style="font-size:smaller;"><strong>■再生中のブロックインデックスの指定</strong></span>(ブロック再生)</p> <table width="100%" cellspacing="1" cellpadding="1" border="1"><tbody><tr><td> <p><span style="font-size:smaller;">playbackBGM.SetNextBlockIndex(cur % this.cueInfo.numBlocks);</span><span style="font-size:smaller;"><br /></span></p> </td> </tr></tbody></table><p><span style="font-size:smaller;"><strong>■再生開始前にブロックをセットして再生</strong></span>(ブロック再生)</p> <table width="100%" cellspacing="1" cellpadding="1" border="1"><tbody><tr><td> <p><span style="font-size:smaller;">atomSourceBgm.cueName = "mainBgm";</span><br /><span style="font-size:smaller;">atomSourceBgm.SetFirstBlockIndex(1);</span><br /><span style="font-size:smaller;">atomSourceBgm.Play();</span><span style="font-size:smaller;"><br /></span></p> </td> </tr></tbody></table><p> </p> <hr /><p><span style="font-size:smaller;"><strong>■スクリプトでのacb解放の仕方</strong></span></p> <table width="100%" cellspacing="1" cellpadding="1" border="1"><tbody><tr><td><span style="font-size:smaller;">if(GUILayout.Button("Remove")){</span><br /><span style="font-size:smaller;">       CriAtom.RemoveCueSheet("PinballMain");</span><br /><span style="font-size:smaller;"> }</span><br /><span style="font-size:smaller;"> if(GUILayout.Button("Add")){</span><br /><span style="font-size:smaller;">       CriAtom.AddCueSheet("PinballMain","PinballMain.acb","");</span><br /><span style="font-size:smaller;"> }</span><span style="font-size:smaller;"><br /></span></td> </tr></tbody></table><p><span style="font-size:smaller;"><strong>■BGMのビートを取り出す(ビート同期する処理)</strong></span></p> <table width="100%" cellspacing="1" cellpadding="1" border="1"><tbody><tr><td> <p><span style="font-size:smaller;">void Start () {</span><br /><span style="font-size:smaller;">    evBeatUpdate += beat; //(デリゲート)</span><br /><span style="font-size:smaller;"><strong>}</strong></span><br /><span style="font-size:smaller;">void beat ()</span><br /><span style="font-size:smaller;">{</span><br /><span style="font-size:smaller;">    Debug.Log("beat" + beatNo.ToString());</span><br /><span style="font-size:smaller;">}<br /> static int beatNo = 0;</span><br /><span style="font-size:smaller;">static int lastBeatNo = 0;</span><br /><span style="font-size:smaller;">public delegate void BeatUpdate ();</span><br /><span style="font-size:smaller;">static public BeatUpdate evBeatUpdate;</span></p> <p><span style="font-size:smaller;">void Update () {</span><br /><span style="font-size:smaller;">    beatNo = (int)(0.001f*(atomSourceBgm.time*82f/60f)); //BPM82</span><br /><span style="font-size:smaller;">    if(lastBeatNo != beatNo){</span><br /><span style="font-size:smaller;">        evBeatUpdate();</span><br /><span style="font-size:smaller;">        lastBeatNo = beatNo;</span><br /><span style="font-size:smaller;">    }</span><br /><span style="font-size:smaller;">}</span><span style="font-size:smaller;"><br /></span></p> </td> </tr></tbody></table><p><span style="font-size:smaller;"><strong>■XYでAISACを変更する(カオシレータ風)</strong></span></p> <table width="100%" cellspacing="1" cellpadding="1" border="1"><tbody><tr><td> <p><span style="font-size:smaller;">// TapPos(new Vector2(x/Screen.width,y/Screen.height));</span></p> <p><span style="font-size:smaller;">static public void TapPos(Vector2 tapPos)</span><br /><span style="font-size:smaller;">{</span><br /><span style="font-size:smaller;">    atomSourceBgm.SetAisac("y",tapPos.y);</span><br /><span style="font-size:smaller;">    atomSourceBgm.SetAisac("x",tapPos.x);</span><br /><span style="font-size:smaller;">}</span><span style="font-size:smaller;"><br /></span></p> </td> </tr></tbody></table><p><span style="font-size:smaller;"><strong>■振幅レベルをとりだす(ピークメータ、口パク等)</strong></span></p> <table width="100%" cellspacing="1" cellpadding="1" border="1"><tbody><tr><td> <p><span style="font-size:smaller;">void Start () {</span><br /><span style="font-size:smaller;">    CriAtomEx.AttachDspBusSetting("DspBusSetting_0"); //バス変更</span><br /><span style="font-size:smaller;">    CriAtom.SetBusAnalyzer(true); // バス解析器を有効化</span><br /><span style="font-size:smaller;">}</span><br /><span style="font-size:smaller;">void Update () {</span><br /><span style="font-size:smaller;">    CriAtomExAsr.BusAnalyzerInfo lBusInfo = CriAtom.GetBusAnalyzerInfo(0); //バス0</span><br /><span style="font-size:smaller;">    Debug.Log("level:" + lBusInfo.peakLevels[0].ToString()); //チャンネル0(Left)</span><br /><span style="font-size:smaller;">}</span><span style="font-size:smaller;"><br /></span></p> </td> </tr></tbody></table><p> <span style="font-size:smaller;"><strong>■MIDIノートNoから音程を設定</strong></span></p> <table width="100%" cellspacing="1" cellpadding="1" border="1"><tbody><tr><td> <p><span style="font-size:smaller;">static public void SetMidiNote(float note)</span><br /><span style="font-size:smaller;">{</span><br /><span style="font-size:smaller;">    atomSourceSe.pitch = (note-69)*100; // cent(100で半音,ベースノート A4=69)</span><br /><span style="font-size:smaller;">}</span></p> </td> </tr></tbody></table><p> </p> <p><span style="font-size:smaller;"> </span><strong>■MIDIベロシティから音量</strong>を設定</p> <table width="100%" cellspacing="1" cellpadding="1" border="1"><tbody><tr><td> <p><span style="font-size:smaller;">static public void VelocityToVoluem(float velocity)</span><br /><span style="font-size:smaller;">{</span><br /><span style="font-size:smaller;">    atomSourceSe.volume = velocity/127f;</span><br /><span style="font-size:smaller;">}</span></p> </td> </tr></tbody></table><p> <span style="font-size:smaller;"><strong>■周波数からピッチ(MIDIノート)の変換</strong></span></p> <table width="100%" cellspacing="1" cellpadding="1" border="1"><tbody><tr><td> <p><span style="font-size:smaller;">static public float Ftom(float freq)</span><br /><span style="font-size:smaller;">{</span><br /><span style="font-size:smaller;">    return (69f + (1f/.057762265f) * Mathf.Log(freq/440f));</span><br /><span style="font-size:smaller;">}</span><span style="font-size:smaller;"><br /></span></p> </td> </tr></tbody></table><p><span style="font-size:smaller;"><strong>■</strong>ピッチ(MIDIノート)から</span>周波数の変換</p> <table width="100%" cellspacing="1" cellpadding="1" border="1"><tbody><tr><td><span style="font-size:smaller;">static public float Mtof(float note)</span><br /><span style="font-size:smaller;">{</span><br /><span style="font-size:smaller;">    return (440f * Mathf.Exp(.057762265f * (note - 69f)));</span><br /><span style="font-size:smaller;">}</span><span style="font-size:smaller;"><br /></span></td> </tr></tbody></table><p><span style="font-size:smaller;"><strong>■ピッチから再生速度へ変換</strong></span></p> <table width="100%" cellspacing="1" cellpadding="1" border="1"><tbody><tr><td><span style="font-size:smaller;">static public float PitchToSpeed(float pitch)</span><br /><span style="font-size:smaller;">{</span><br /><span style="font-size:smaller;">    return Mathf.Pow(2,pitch/12.0f);</span><br /><span style="font-size:smaller;">}</span><span style="font-size:smaller;"><br /></span></td> </tr></tbody></table><p><span style="font-size:smaller;"><strong>【補足】Unityの標準再生などの再生速度指定系でピッチを指定したい場合に使います。ADX2LEでは再生速度指定AISACなどで使うかも。</strong></span><br /><span style="font-size:smaller;"><strong><br /> ■iOSなどバックグラウンドになった時にBGMを一時停止/復帰する</strong></span></p> <table width="100%" cellspacing="1" cellpadding="1" border="1"><tbody><tr><td> <p><span style="font-size:smaller;">void OnApplicationPause(bool pause)</span><br /><span style="font-size:smaller;">{</span><br /><span style="font-size:smaller;">    atomSourceBgm.Pause(pause);</span><br /><span style="font-size:smaller;">}</span><span style="font-size:smaller;"><br /></span></p> </td> </tr></tbody></table><p>  【補足】iOSなどスプリングボードへ移動する瞬間などの若干のフェードアウトしている間も音は再生されています。これを使うことでほんの少し抑制できます。</p> <p><span style="font-size:smaller;"><strong>■キューブをクリックすると再生/停止をする</strong></span><br /><span style="font-size:smaller;">- CubeにCriAtomSourceをつけて、cri/unity/samples/criatom/script/Unity3Project/ScriptSample01_ClickToPlay/Assets/</span><span style="font-size:smaller;">Scripts/PlayAndStopSoundOnClick.csを使う。</span><span style="font-size:smaller;"> </span></p> <table width="100%" cellspacing="1" cellpadding="1" border="1"><tbody><tr><td> <p><span style="font-size:smaller;">    void Update () {</span><br /><span style="font-size:smaller;">        if (Input.GetMouseButtonDown(0)){</span><br /><span style="font-size:smaller;">            Ray clkRay = Camera.main.ScreenPointToRay(Input.mousePosition);</span><br /><span style="font-size:smaller;">            RaycastHit rh;</span><br /><span style="font-size:smaller;">            // Collision Dectection</span></p> <p><span style="font-size:smaller;">            if (Physics.Raycast(clkRay, out rh, 20)) {</span><br /><span style="font-size:smaller;">                GameObject target = rh.collider.gameObject;</span><br /><span style="font-size:smaller;">                if (target == this.gameObject) {</span></p> <p><span style="font-size:smaller;">                    // Play Cue</span><br /><span style="font-size:smaller;">                    CriAtomSource atom_src = target.GetComponent&lt;CriAtomSource&gt;();</span><br /><span style="font-size:smaller;">                    if (atom_src != null) {</span><br /><span style="font-size:smaller;">                        CriAtomSource.Status status = atom_src.status;</span><br /><span style="font-size:smaller;">                        if ((status == CriAtomSource.Status.Stop) || (status == CriAtomSource.Status.PlayEnd)) {</span><br /><span style="font-size:smaller;">                            atom_src.Play();</span><br /><span style="font-size:smaller;">                        } else {</span><br /><span style="font-size:smaller;">                            atom_src.Stop();</span><br /><span style="font-size:smaller;">                        }</span><br /><span style="font-size:smaller;">                    }</span><br /><span style="font-size:smaller;">                }</span><br /><span style="font-size:smaller;">            }</span><br /><span style="font-size:smaller;">        }</span><br /><span style="font-size:smaller;">    }</span></p> </td> </tr></tbody></table><p> </p> <hr /><p><a name="CriAtomExPlayer"></a></p> <p>■AtomSourceからCriAtomExPlayerを得る(<a href="http://www53.atwiki.jp/soundtasukeai/pages/21.html#CriAtomExPlayer">CriAtomExPlayerを呼び出す改良</a>)<br /> Plugins/CriWare/CriWare/CriAtomSource.csに以下の行を追加</p> <table width="100%" cellspacing="1" cellpadding="1" border="1"><tbody><tr><td>    public CriAtomExPlayer Player<br />     {<br />         get {<br />             return player;   <br />         }<br />     }</td> </tr></tbody></table><p>【補足】CriAtomExPlayerはpitchの変更やtimeの設定など低レベルなリアルタイム処理を使用する場合に取得します。</p> <p><a name="seek">■シークして再生</a></p> <table width="100%" cellspacing="1" cellpadding="1" border="1"><tbody><tr><td>atomSourceSe.Player.SetStartTime((long)settime);   <br /> atomSourceSe.Stop();<br /> atomSourceSe.Play(cueNo);  </td> </tr></tbody></table><p> 【補足】CriAtomExPlayerのSetStartTimeを呼び出すため、<a href="#CriAtomExPlayer">CriAtomExPlayerを呼び出す改良</a>を施しておいて下さい。SetStartTimeには開始msecを指定します。</p> <p>■再生中の音をピッチベンドする</p> <table width="100%" cellspacing="1" cellpadding="1" border="1"><tbody><tr><td>CriAtomExPlayback playback;<br /> void Playback(int cueNo)<br /> {<br />   playback = atomSourceSe.Play(cueNo);<br /> }<br /> void PitchBend(float pitch){<br />   atomSourceSe.Player.SetPitch(pitch);   <br />   atomSourceSe.Player.Update(playback);<br /> }</td> </tr></tbody></table><p>【補足】CriAtomExPlayerのSetStartTimeを呼び出すため、<a href="#CriAtomExPlayer">CriAtomExPlayerを呼び出す改良</a>を施しておいて下さい。SetPitchにはcent値(100で半音、1200で1オクターブ)を指定します。<br /> playbackを取得して、Updateしたタイミングで再生中の音に反映します。</p> <p> </p> <p> </p> <p> </p> <p> </p> </div> <hr /><hr /><hr /><hr /><p> </p>
<p>ADX2 LE情報(<a name="http:__www.facebook.com_groups_adx2userj_files_">facebook ADX2ユーザー助け合い所</a>からコピー)<span style="font-size:smaller;"><br /></span></p> <p><span style="font-size:smaller;">検索にひっかかるようにwikiにADX2LEでのスクリプトのヒント集をwikiにまとめてみました。</span></p> <div class="mtl fbDocument"> <p><span style="font-size:smaller;"><strong>■効果音を作りたい</strong></span></p> <table width="100%" cellspacing="1" cellpadding="1" border="1"><tbody><tr><td> <p><a href="http://www.slideshare.net/tatmos/adx2le-ggj13/33" target="_blank"><span style="font-size:smaller;">http://www.slideshare.net/tatmos/adx2le-ggj13/33</span></a><span style="font-size:smaller;"><br /> の33ページから「爆発音」「レーザー音」「サイレン音」など作ってみましょう。</span><span style="font-size:smaller;"><br /></span></p> </td> </tr></tbody></table><p><span style="font-size:smaller;"><strong>■初期化手順</strong></span></p> <table width="100%" cellspacing="1" cellpadding="1" border="1"><tbody><tr><td> <p><span style="font-size:smaller;"><strong>CRIメニュー</strong>から<br /> ①<strong>Create CRIWARE Libraly Initializer</strong>初期化オブジェクトをシーン追加<br /> ②<strong>Create CRIWARE Error Handler</strong>エラーハンドラをシーン追加<br /> ③<strong>Open CRI Atom Window ...</strong></span><br /><span style="font-size:smaller;">から</span><br /><span style="font-size:smaller;"><strong>Select Assets Root</strong>で[Atom Craftの出力したAssetsフォルダ]を指定</span><br /><span style="font-size:smaller;"><strong>Update Assets of "CRI Atom Craft"</strong>で更新</span><br /><span style="font-size:smaller;">④Unityを一度バックグラウンドに(デスクトップ表示など)して戻し、</span><br /><span style="font-size:smaller;">CRI Atomウィンドウをクリック</span><span style="font-size:smaller;"><br /></span></p> </td> </tr></tbody></table><p> <span style="font-size:smaller;"><strong>■CriAtomSouceコンポーネントの追加</strong></span></p> <table width="100%" cellspacing="1" cellpadding="1" border="1"><tbody><tr><td><span style="font-size:smaller;">atomSourceSe = gameObject.AddComponent&lt;CriAtomSource&gt; ();</span><br /><span style="font-size:smaller;">atomSourceSe.cueSheet = cueSheetName; //キューシート名指定</span><span style="font-size:smaller;"><br /></span></td> </tr></tbody></table><p>【補足】AtomSouceコンポーネントをスクリプトで作りたい場合の例です。</p> <p><span style="font-size:smaller;"><strong>■再生/停止/ポーズ/ポーズ解除</strong></span></p> <table width="100%" cellspacing="1" cellpadding="1" border="1"><tbody><tr><td> <p><span style="font-size:smaller;">atomSourceSe.Play(4); // キューID指定再生</span><br /><span style="font-size:smaller;">atomSourceSe.Play(“orchehit”); //キュー名指定再生</span><br /><span style="font-size:smaller;">atomSourceSe.Stop();</span><br /><span style="font-size:smaller;">atomSourceSe.Pause(true);</span><br /><span style="font-size:smaller;">atomSourceSe.Pause(false);</span><span style="font-size:smaller;"><br /></span></p> </td> </tr></tbody></table><p><span style="font-size:smaller;"><strong>■Pitch/Volume変更</strong></span></p> <table width="100%" cellspacing="1" cellpadding="1" border="1"><tbody><tr><td><span style="font-size:smaller;">atomSourceSe.pitch = 100; // cent(100で半音)</span><br /><span style="font-size:smaller;">atomSourceSe.volume = 1.0f;   // 1.0で原音と同じ振幅レベル</span></td> </tr></tbody></table><p><span style="font-size:smaller;"><strong>■AISAC変更</strong></span></p> <table width="100%" cellspacing="1" cellpadding="1" border="1"><tbody><tr><td> <p><span style="font-size:smaller;">atomSourceSe.SetAisac(aisac_id,value);//AISACコントロールID指定</span><br /><span style="font-size:smaller;">atomSourceSe.SetAisac(“Any”,value); //AISACコントロール名指定</span><span style="font-size:smaller;"><br /></span></p> </td> </tr></tbody></table><p> <span style="font-size:smaller;"><strong>■カテゴリボリューム変更</strong></span></p> <table width="100%" cellspacing="1" cellpadding="1" border="1"><tbody><tr><td> <p><span style="font-size:smaller;">CriAtom.SetCategoryVolume("BGM",bgmVolume);</span><span style="font-size:smaller;"><br /></span></p> </td> </tr></tbody></table><p> </p> <p><span style="font-size:smaller;"><strong>■バスセンド(リバーブ量変化等)</strong></span></p> <table width="100%" cellspacing="1" cellpadding="1" border="1"><tbody><tr><td> <p><span style="font-size:smaller;">float depth = 1.0f;</span><br /><span style="font-size:smaller;">int busNo = 1; //reverb</span><br /><span style="font-size:smaller;">atomSourceSe.SetBusSendLevelOffset(busNo,depth);</span><span style="font-size:smaller;"><br /></span></p> </td> </tr></tbody></table><p> </p> <p><span style="font-size:smaller;"><strong>■再生時刻の取得</strong></span></p> <table width="100%" cellspacing="1" cellpadding="1" border="1"><tbody><tr><td> <p><span style="font-size:smaller;">GUILayout.Label(atomSourceBgm.time.ToString());</span><span style="font-size:smaller;"><br /></span></p> </td> </tr></tbody></table><p> </p> <p><span style="font-size:smaller;"><strong>■再生状態の取得</strong></span></p> <table width="100%" cellspacing="1" cellpadding="1" border="1"><tbody><tr><td><span style="font-size:smaller;">CriAtomSource.Status status = atomSourceBgm.status;</span><br /><span style="font-size:smaller;">   if ((status == CriAtomSource.Status.Stop) || (status == CriAtomSource.Status.PlayEnd)) {</span>//停止かエンドか<br /><span style="font-size:smaller;">       this.playbackBGM = atomSourceBgm.Play(100);</span><br /><span style="font-size:smaller;"> }</span><span style="font-size:smaller;"><br /></span></td> </tr></tbody></table><p><span style="font-size:smaller;"><strong>■キュー情報一括取得</strong></span></p> <table width="100%" cellspacing="1" cellpadding="1" border="1"><tbody><tr><td> <p><span style="font-size:smaller;">string cueSheetName = “Pinball”;</span><br /><span style="font-size:smaller;">CriAtomExAcb acb = CriAtom.GetAcb (cueSheetName);</span><br /><span style="font-size:smaller;">CriAtomEx.CueInfo[] cueInfoList = acb.GetCueInfoList ();</span><span style="font-size:smaller;"><br /></span></p> </td> </tr></tbody></table><hr /><p><span style="font-size:smaller;"><strong>■再生中のブロックインデックスの取得</strong></span>(ブロック再生)</p> <table width="100%" cellspacing="1" cellpadding="1" border="1"><tbody><tr><td> <p><span style="font-size:smaller;">CriAtomExPlayback playbackBGM;</span><br /><span style="font-size:smaller;">playbackBGM = atomSourceBgm.Play(100);</span><br /><span style="font-size:smaller;">int cur = this.playbackBGM.GetCurrentBlockIndex();</span><span style="font-size:smaller;"><br /></span></p> </td> </tr></tbody></table><p> </p> <p><span style="font-size:smaller;"><strong>■再生中のブロックインデックスの指定</strong></span>(ブロック再生)</p> <table width="100%" cellspacing="1" cellpadding="1" border="1"><tbody><tr><td> <p><span style="font-size:smaller;">playbackBGM.SetNextBlockIndex(cur % this.cueInfo.numBlocks);</span><span style="font-size:smaller;"><br /></span></p> </td> </tr></tbody></table><p><span style="font-size:smaller;"><strong>■再生開始前にブロックをセットして再生</strong></span>(ブロック再生)</p> <table width="100%" cellspacing="1" cellpadding="1" border="1"><tbody><tr><td> <p><span style="font-size:smaller;">atomSourceBgm.cueName = "mainBgm";</span><br /><span style="font-size:smaller;">atomSourceBgm.SetFirstBlockIndex(1);</span><br /><span style="font-size:smaller;">atomSourceBgm.Play();</span><span style="font-size:smaller;"><br /></span></p> </td> </tr></tbody></table><p> </p> <hr /><p><span style="font-size:smaller;"><strong>■スクリプトでのacb解放の仕方</strong></span></p> <table width="100%" cellspacing="1" cellpadding="1" border="1"><tbody><tr><td><span style="font-size:smaller;">if(GUILayout.Button("Remove")){</span><br /><span style="font-size:smaller;">       CriAtom.RemoveCueSheet("PinballMain");</span><br /><span style="font-size:smaller;"> }</span><br /><span style="font-size:smaller;"> if(GUILayout.Button("Add")){</span><br /><span style="font-size:smaller;">       CriAtom.AddCueSheet("PinballMain","PinballMain.acb","");</span><br /><span style="font-size:smaller;"> }</span><span style="font-size:smaller;"><br /></span></td> </tr></tbody></table><p><span style="font-size:smaller;"><strong>■BGMのビートを取り出す(ビート同期する処理)</strong></span></p> <table width="100%" cellspacing="1" cellpadding="1" border="1"><tbody><tr><td> <p><span style="font-size:smaller;">void Start () {</span><br /><span style="font-size:smaller;">    evBeatUpdate += beat; //(デリゲート)</span><br /><span style="font-size:smaller;"><strong>}</strong></span><br /><span style="font-size:smaller;">void beat ()</span><br /><span style="font-size:smaller;">{</span><br /><span style="font-size:smaller;">    Debug.Log("beat" + beatNo.ToString());</span><br /><span style="font-size:smaller;">}<br /> static int beatNo = 0;</span><br /><span style="font-size:smaller;">static int lastBeatNo = 0;</span><br /><span style="font-size:smaller;">public delegate void BeatUpdate ();</span><br /><span style="font-size:smaller;">static public BeatUpdate evBeatUpdate;</span></p> <p><span style="font-size:smaller;">void Update () {</span><br /><span style="font-size:smaller;">    beatNo = (int)(0.001f*(atomSourceBgm.time*82f/60f)); //BPM82</span><br /><span style="font-size:smaller;">    if(lastBeatNo != beatNo){</span><br /><span style="font-size:smaller;">        evBeatUpdate();</span><br /><span style="font-size:smaller;">        lastBeatNo = beatNo;</span><br /><span style="font-size:smaller;">    }</span><br /><span style="font-size:smaller;">}</span><span style="font-size:smaller;"><br /></span></p> </td> </tr></tbody></table><p><span style="font-size:smaller;"><strong>■XYでAISACを変更する(カオシレータ風)</strong></span></p> <table width="100%" cellspacing="1" cellpadding="1" border="1"><tbody><tr><td> <p><span style="font-size:smaller;">// TapPos(new Vector2(x/Screen.width,y/Screen.height));</span></p> <p><span style="font-size:smaller;">static public void TapPos(Vector2 tapPos)</span><br /><span style="font-size:smaller;">{</span><br /><span style="font-size:smaller;">    atomSourceBgm.SetAisac("y",tapPos.y);</span><br /><span style="font-size:smaller;">    atomSourceBgm.SetAisac("x",tapPos.x);</span><br /><span style="font-size:smaller;">}</span><span style="font-size:smaller;"><br /></span></p> </td> </tr></tbody></table><p><span style="font-size:smaller;"><strong>■振幅レベルをとりだす(ピークメータ、口パク等)</strong></span></p> <table width="100%" cellspacing="1" cellpadding="1" border="1"><tbody><tr><td> <p><span style="font-size:smaller;">void Start () {</span><br /><span style="font-size:smaller;">    CriAtomEx.AttachDspBusSetting("DspBusSetting_0"); //バス変更</span><br /><span style="font-size:smaller;">    CriAtom.SetBusAnalyzer(true); // バス解析器を有効化</span><br /><span style="font-size:smaller;">}</span><br /><span style="font-size:smaller;">void Update () {</span><br /><span style="font-size:smaller;">    CriAtomExAsr.BusAnalyzerInfo lBusInfo = CriAtom.GetBusAnalyzerInfo(0); //バス0</span><br /><span style="font-size:smaller;">    Debug.Log("level:" + lBusInfo.peakLevels[0].ToString()); //チャンネル0(Left)</span><br /><span style="font-size:smaller;">}</span><span style="font-size:smaller;"><br /></span></p> </td> </tr></tbody></table><p> <span style="font-size:smaller;"><strong>■MIDIノートNoから音程を設定</strong></span></p> <table width="100%" cellspacing="1" cellpadding="1" border="1"><tbody><tr><td> <p><span style="font-size:smaller;">static public void SetMidiNote(float note)</span><br /><span style="font-size:smaller;">{</span><br /><span style="font-size:smaller;">    atomSourceSe.pitch = (note-69)*100; // cent(100で半音,ベースノート A4=69)</span><br /><span style="font-size:smaller;">}</span></p> </td> </tr></tbody></table><p> </p> <p><span style="font-size:smaller;"> </span><strong>■MIDIベロシティから音量</strong>を設定</p> <table width="100%" cellspacing="1" cellpadding="1" border="1"><tbody><tr><td> <p><span style="font-size:smaller;">static public void VelocityToVoluem(float velocity)</span><br /><span style="font-size:smaller;">{</span><br /><span style="font-size:smaller;">    atomSourceSe.volume = velocity/127f;</span><br /><span style="font-size:smaller;">}</span></p> </td> </tr></tbody></table><p> <span style="font-size:smaller;"><strong>■周波数からピッチ(MIDIノート)の変換</strong></span></p> <table width="100%" cellspacing="1" cellpadding="1" border="1"><tbody><tr><td> <p><span style="font-size:smaller;">static public float Ftom(float freq)</span><br /><span style="font-size:smaller;">{</span><br /><span style="font-size:smaller;">    return (69f + (1f/.057762265f) * Mathf.Log(freq/440f));</span><br /><span style="font-size:smaller;">}</span><span style="font-size:smaller;"><br /></span></p> </td> </tr></tbody></table><p><span style="font-size:smaller;"><strong>■</strong>ピッチ(MIDIノート)から</span>周波数の変換</p> <table width="100%" cellspacing="1" cellpadding="1" border="1"><tbody><tr><td><span style="font-size:smaller;">static public float Mtof(float note)</span><br /><span style="font-size:smaller;">{</span><br /><span style="font-size:smaller;">    return (440f * Mathf.Exp(.057762265f * (note - 69f)));</span><br /><span style="font-size:smaller;">}</span><span style="font-size:smaller;"><br /></span></td> </tr></tbody></table><p><span style="font-size:smaller;"><strong>■ピッチから再生速度へ変換</strong></span></p> <table width="100%" cellspacing="1" cellpadding="1" border="1"><tbody><tr><td><span style="font-size:smaller;">static public float PitchToSpeed(float pitch)</span><br /><span style="font-size:smaller;">{</span><br /><span style="font-size:smaller;">    return Mathf.Pow(2,pitch/12.0f);</span><br /><span style="font-size:smaller;">}</span><span style="font-size:smaller;"><br /></span></td> </tr></tbody></table><p><span style="font-size:smaller;"><strong>【補足】Unityの標準再生などの再生速度指定系でピッチを指定したい場合に使います。ADX2LEでは再生速度指定AISACなどで使うかも。</strong></span><br /><span style="font-size:smaller;"><strong><br /> ■iOSなどバックグラウンドになった時にBGMを一時停止/復帰する</strong></span></p> <table width="100%" cellspacing="1" cellpadding="1" border="1"><tbody><tr><td> <p><span style="font-size:smaller;">void OnApplicationPause(bool pause)</span><br /><span style="font-size:smaller;">{</span><br /><span style="font-size:smaller;">    atomSourceBgm.Pause(pause);</span><br /><span style="font-size:smaller;">}</span><span style="font-size:smaller;"><br /></span></p> </td> </tr></tbody></table><p>  【補足】iOSなどスプリングボードへ移動する瞬間などの若干のフェードアウトしている間も音は再生されています。これを使うことでほんの少し抑制できます。</p> <p><span style="font-size:smaller;"><strong>■キューブをクリックすると再生/停止をする</strong></span><br /><span style="font-size:smaller;">- CubeにCriAtomSourceをつけて、cri/unity/samples/criatom/script/Unity3Project/ScriptSample01_ClickToPlay/Assets/</span><span style="font-size:smaller;">Scripts/PlayAndStopSoundOnClick.csを使う。</span><span style="font-size:smaller;"> </span></p> <table width="100%" cellspacing="1" cellpadding="1" border="1"><tbody><tr><td> <p><span style="font-size:smaller;">    void Update () {</span><br /><span style="font-size:smaller;">        if (Input.GetMouseButtonDown(0)){</span><br /><span style="font-size:smaller;">            Ray clkRay = Camera.main.ScreenPointToRay(Input.mousePosition);</span><br /><span style="font-size:smaller;">            RaycastHit rh;</span><br /><span style="font-size:smaller;">            // Collision Dectection</span></p> <p><span style="font-size:smaller;">            if (Physics.Raycast(clkRay, out rh, 20)) {</span><br /><span style="font-size:smaller;">                GameObject target = rh.collider.gameObject;</span><br /><span style="font-size:smaller;">                if (target == this.gameObject) {</span></p> <p><span style="font-size:smaller;">                    // Play Cue</span><br /><span style="font-size:smaller;">                    CriAtomSource atom_src = target.GetComponent&lt;CriAtomSource&gt;();</span><br /><span style="font-size:smaller;">                    if (atom_src != null) {</span><br /><span style="font-size:smaller;">                        CriAtomSource.Status status = atom_src.status;</span><br /><span style="font-size:smaller;">                        if ((status == CriAtomSource.Status.Stop) || (status == CriAtomSource.Status.PlayEnd)) {</span><br /><span style="font-size:smaller;">                            atom_src.Play();</span><br /><span style="font-size:smaller;">                        } else {</span><br /><span style="font-size:smaller;">                            atom_src.Stop();</span><br /><span style="font-size:smaller;">                        }</span><br /><span style="font-size:smaller;">                    }</span><br /><span style="font-size:smaller;">                }</span><br /><span style="font-size:smaller;">            }</span><br /><span style="font-size:smaller;">        }</span><br /><span style="font-size:smaller;">    }</span></p> </td> </tr></tbody></table><p> </p> <hr /><p><a name="CriAtomExPlayer"></a></p> <p>■AtomSourceからCriAtomExPlayerを得る(<a href="http://www53.atwiki.jp/soundtasukeai/pages/21.html#CriAtomExPlayer">CriAtomExPlayerを呼び出す改良</a>)<br /> Plugins/CriWare/CriWare/CriAtomSource.csに以下の行を追加</p> <table width="100%" cellspacing="1" cellpadding="1" border="1"><tbody><tr><td>    public CriAtomExPlayer Player<br />     {<br />         get {<br />             return player;   <br />         }<br />     }</td> </tr></tbody></table><p>【補足】CriAtomExPlayerはpitchの変更やtimeの設定など低レベルなリアルタイム処理を使用する場合に取得します。</p> <p><a name="seek">■シークして再生</a></p> <table width="100%" cellspacing="1" cellpadding="1" border="1"><tbody><tr><td>atomSourceSe.Player.SetStartTime((long)settime);   <br /> atomSourceSe.Stop();<br /> atomSourceSe.Play(cueNo);  </td> </tr></tbody></table><p> 【補足】CriAtomExPlayerのSetStartTimeを呼び出すため、<a href="#CriAtomExPlayer">CriAtomExPlayerを呼び出す改良</a>を施しておいて下さい。SetStartTimeには開始msecを指定します。</p> <p>■再生中の音をピッチベンドする</p> <table width="100%" cellspacing="1" cellpadding="1" border="1"><tbody><tr><td>CriAtomExPlayback playback;<br /> void Playback(int cueNo)<br /> {<br />   playback = atomSourceSe.Play(cueNo);<br /> }<br /> void PitchBend(float pitch){<br />   atomSourceSe.Player.SetPitch(pitch);   <br />   atomSourceSe.Player.Update(playback);<br /> }</td> </tr></tbody></table><p>【補足】CriAtomExPlayerのSetStartTimeを呼び出すため、<a href="#CriAtomExPlayer">CriAtomExPlayerを呼び出す改良</a>を施しておいて下さい。SetPitchにはcent値(100で半音、1200で1オクターブ)を指定します。<br /> playbackを取得して、Updateしたタイミングで再生中の音に反映します。</p> <p> </p> <p> </p> <p> </p> <p> </p> </div> <hr /><hr /><hr /><hr /><p> </p>

表示オプション

横に並べて表示:
変化行の前後のみ表示: