PHPマメ知識
2008年1月28日
意外にPHP初心者なワタシです。
PHPで連想配列の先頭に追加する方法
連想配列にarray_unshiftをしようと、
$itemlistという連想配列に
array_unshift($itemlist, ‘’=>’すべてのアイテム’);
と記述したところエラー、
array_unshift($itemlist, ‘すべてのアイテム’);
としたところ添え字が「0」となってしまう。
ワタシの要望では添え字は「(空)」にしたいと思っております。
■解決方法■
お世話になった記事
http://ml.php.gr.jp/pipermail/php-users/2004-June/022713.html
$tmp = array('’ => ‘すべてのアイテム’);
$itemlist = $tmp + $itemlist;
で、デキマシタ!
先輩方ありがとうございます。
symfony(sf_sandbox)のディレクトリ移行
2008年1月23日
[Csound] csound5 インストールメモ
2008年1月21日
csound5をLinuxサーバにインストールしたときのメモ。
<事前準備>
sconsのインストール
http://sourceforge.net/project/showfiles.php?group_id=30337
rootでインストールを実行
# rpm -Uvh scons-0.97.0d20071212-1.noarch.rpm
libsndfileのインストール
http://www.mega-nerd.com/libsndfile/#Download
% tar zxvf libsndfile-1.0.17.tar.gz
% cd libsndfile-1.0.17
% ./configure
% make
% make check
% su
# make install
前のcsound4をアンインストール
インストールしたディレクトリで:
# make uninstall
<csound5のインストール>
% tar zxvf Csound5.07.0.tar.gz
% cd csound5
% scons -h
(設定を変更するならここでcustom.pyを編集したり次のコマンドでオプションを指定したりすると思うのだが、今回は何もせずにコンパイル実行)
% scons
% su
# ./install.py
<インストール結果>
=== Installing executables ===
/usr/local/bin/csound
/usr/local/bin/cvanal
/usr/local/bin/dnoise
/usr/local/bin/envext
/usr/local/bin/extractor
/usr/local/bin/het_export
/usr/local/bin/het_import
/usr/local/bin/hetro
/usr/local/bin/lpanal
/usr/local/bin/lpc_export
/usr/local/bin/lpc_import
/usr/local/bin/mixer
/usr/local/bin/pvanal
/usr/local/bin/pv_export
/usr/local/bin/pv_import
/usr/local/bin/pvlook
/usr/local/bin/scale
/usr/local/bin/sndinfo
/usr/local/bin/srconv
/usr/local/bin/scsort
/usr/local/bin/extract
/usr/local/bin/cs
/usr/local/bin/csb64enc
/usr/local/bin/makecsd
/usr/local/bin/scot
/usr/local/bin/brkpt
/usr/local/bin/linseg
/usr/local/bin/tabdes
=== Installing libraries ===
/usr/local/lib/libcsound.a
=== Installing plugins ===
/usr/local/lib/csound/plugins/libsystem_call.so
/usr/local/lib/csound/plugins/librtalsa.so
/usr/local/lib/csound/plugins/libscansyn.so
/usr/local/lib/csound/plugins/libudpsend.so
/usr/local/lib/csound/plugins/libpitch.so
/usr/local/lib/csound/plugins/libugakbari.so
/usr/local/lib/csound/plugins/libgabnew.so
/usr/local/lib/csound/plugins/libdate.so
/usr/local/lib/csound/plugins/libampmidid.so
/usr/local/lib/csound/plugins/libsfont.so
/usr/local/lib/csound/plugins/libstackops.so
/usr/local/lib/csound/plugins/libpvoc.so
/usr/local/lib/csound/plugins/libpartikkel.so
/usr/local/lib/csound/plugins/libbabo.so
/usr/local/lib/csound/plugins/libpvsbuffer.so
/usr/local/lib/csound/plugins/libloscilx.so
/usr/local/lib/csound/plugins/libcontrol.so
/usr/local/lib/csound/plugins/libharmon.so
/usr/local/lib/csound/plugins/libphysmod.so
/usr/local/lib/csound/plugins/libstdutil.so
/usr/local/lib/csound/plugins/libminmax.so
/usr/local/lib/csound/plugins/libeqfil.so
/usr/local/lib/csound/plugins/libscoreline.so
/usr/local/lib/csound/plugins/libptrack.so
/usr/local/lib/csound/plugins/libphisem.so
/usr/local/lib/csound/plugins/libudprecv.so
/usr/local/lib/csound/plugins/libpvs_ops.so
/usr/local/lib/csound/plugins/libvbap.so
/usr/local/lib/csound/plugins/libcompress.so
/usr/local/lib/csound/plugins/libftest.so
/usr/local/lib/csound/plugins/libhrtferX.so
/usr/local/lib/csound/plugins/libbarmodel.so
/usr/local/lib/csound/plugins/libmixer.so
/usr/local/lib/csound/plugins/libpan2.so
/usr/local/lib/csound/plugins/libmodal4.so
/usr/local/lib/csound/plugins/libmutexops.so
/usr/local/lib/csound/plugins/libvaops.so
/usr/local/lib/csound/plugins/libgrain4.so
/usr/local/lib/csound/plugins/libstdopcod.so
=== Installing header files ===
/usr/local/include/csound/cfgvar.h
/usr/local/include/csound/cscore.h
/usr/local/include/csound/csdl.h
/usr/local/include/csound/csound.h
/usr/local/include/csound/csound.hpp
/usr/local/include/csound/csoundCore.h
/usr/local/include/csound/cwindow.h
/usr/local/include/csound/msg_attr.h
/usr/local/include/csound/OpcodeBase.hpp
/usr/local/include/csound/pstream.h
/usr/local/include/csound/pvfileio.h
/usr/local/include/csound/soundio.h
/usr/local/include/csound/sysdep.h
/usr/local/include/csound/text.h
/usr/local/include/csound/version.h
/usr/local/include/csound/CppSound.hpp
/usr/local/include/csound/filebuilding.h
/usr/local/include/csound/CsoundFile.hpp
=== Installing language interfaces ===
/usr/lib/python2.3/site-packages/csnd.py
/usr/lib/python2.3/site-packages/loris.py
/usr/local/lib/csound/java/csnd.jar
=== Installing XMG files ===
/usr/local/share/csound/xmg/English.xmg
/usr/local/share/csound/xmg/American.xmg
/usr/local/share/csound/xmg/csound.xmg
=== Installing documentation ===
/usr/local/share/doc/csound/COPYING
/usr/local/share/doc/csound/ChangeLog
/usr/local/share/doc/csound/INSTALL
/usr/local/share/doc/csound/readme-csound5.txt
=== Installing Tcl/Tk modules and scripts ===
/usr/local/lib/csound/tcl/nsliders.tk
/usr/local/bin/matrix.tk
=== Installing uninstall script ===
/usr/local/bin/uninstall-csound5
=== Installing MD5 checksums ===
/usr/local/csound5-2008-01-21.md5sums
Csound installation has been successfully completed.
Before running Csound, make sure that the following environment
variables are set:
OPCODEDIR=/usr/local/lib/csound/plugins
CSSTRNGS=/usr/local/share/csound/xmg
Csound can be uninstalled by running /usr/local/bin/uninstall-csound5
<参考>
http://d.hatena.ne.jp/A9A9/20070815/1187184234
http://www.csounds.com/manual/html/BuildingCsound.html
漢字でモザイク
2008年1月9日

<開発環境>
PHP4.4.7 + GDライブラリ + MySQL4.1.22
<前処理:漢字のデータベース化>
(1)
常用漢字を順番に一文字ずつ画像として作成
画像例:
(2)
漢字画像の各ピクセルの明度の平均値を計算し、その漢字の明度とする
(3)
漢字とその明度をデータベースに保存
<表示処理:画像のモザイク化>
(1)
画像を10ピクセルごとの明度の平均値を計算し、モノクロのモザイクデータを作成
(2)
明度に近い漢字をデータベースから抽出
(3)
表示
———-
テキストなので、
・指定した文章の文字を使用する
・フォント/サイズを変更する
・テキストのアニメーション
など応用ができそう。
今回はとりあえずそのための準備、という感じ。
ソニックジャムの年賀コンテンツ
2008年1月7日
あけましておめでとうございます。
本年もどうぞよろしくお願い申し上げます。
日ごろの感謝の気持ちをこめてみなさまに新年のご挨拶をすべく、
年賀コンテンツを公開しました。
社員がネズミの格好で今年の抱負を発表しております。
選んだ社員のキャラで入力した文字を話させることもできるので、
好きな言葉を入れてみてください。
■仕組み
1.
音声変換を含む基本メニュー部分(swf)と、社員3D表示エリア(dir)を分割して作成
(クロスドメイン対応・今後の汎用化を考慮し基本メニュー用swfを切り離した)
2.
dirには音声・メニュー操作と同期をとるためのswfを組み込む
3.
その組み込んだswfと基本メニュー部分はLocalConnectionにより通信し、
音声とアニメーション・メニュー操作等の同期をとっている
4.
基本メニューswfからphpへ文字列をサーバーへ送信
5.
サーバー側は受信した文字列をもとにmp3を生成、
生成したmp3のパスを基本メニューswfへ返す
6.
基本メニューswfは返ってきたパスを元にmp3を読み込み音声を再生させる
■mp3の生成
入力されたテキストはGalateaの音声部分であるGalateaTalkを使用して音声合成を行っています。
GalateaTalkからは、RAW形式で出力されるのでwav形式へ変換。
Flashから再生出来るよう再度、wav形式からmp3形式へ変換を行っています。
Flashでの再生のため、固定ビットレート(CBR)で出力しています。
■スタッフの3D化について
年賀コンテンツに因みネズミの格好をした社員のモデルとアニメーションを作成。
Lightwaveで作成した後shockwave3D形式で書き出します。
書き出されたshockwave3DをDirector MX2004に読み込みオーサリングしています。
【できたらいいなと思うこと】
・英語対応。
・今回インパクトを優先させるため、dirを使用していますが、
一般への波及効果を考えるとFlashのみのコンテンツも。
(例:flash 3D(as3)+音声変換コンテンツ)
(例:音声変換のみ使用したFlashコンテンツ)
また、以前試した音声認識と組み合わせると、対話型のインターフェースも実装可能と考えています。
——–Special Thanks of technic—————-
■技術
Galatea Project
http://hil.t.u-tokyo.ac.jp/~galatea/index-jp.html
RAWからwavへの変換:SoX - Sound eXchange
http://sox.sourceforge.net/
wavからmp3への変換:The LAME Project
http://lame.sourceforge.net/index.php
