ライセンスはGPLですが、MPEG decoding codeを含めなければBSDとして利用できます。snack2.2.10\README
| 拡張パッケージ | ライブラリ | 内容 |
|---|---|---|
| libsnack.dll | Snackパッケージ | |
| sound | libsound.dll | Snackパッケージからグラフィックに関する処理を除いたもの |
| snackogg | libsnackogg.dll | Ogg Vorbis形式のサポートを追加 |
| snacksphere | libsnacksphere.dll | NIST Sphere形式のサポートを追加 |
Windowsで使用するならば32bit版のActiveTclをインストールし、Wishを起動します。そしてConsoleに次のように記述し、Snackのパッケージを読み込みます。
(bin) 1 % package require snack
このとき「can't find package snack」となるならば、ダウンロードしたSnackのバイナリのbin\windowsへパスを通すか、パスが通っている場所へ配置します。
「couldn't load library "C:/ActiveTcl/lib/snack/libsnack.dll": invalid argument」となるならば、64bit版のActiveTclを使用していないか確認します。problem with using the Snack lib - solved now | ActiveState Community Site
(bin) 1 % package require snack 2.2
のように、バージョン番号が出力されたら成功です。次にSoundオブジェクトを作成します。
(bin) 2 % snack::sound s s
そうしたらreadコマンドを用いて、Soundオブジェクトに音ファイルを読み込めます。
(bin) 3 % s read ex1.wav WAV
同様にplayコマンドを用いれば、音を再生できます。
(bin) 4 % s play
Windows環境ならば、Visual C++ 6.0向けのプロジェクトwin\snack.dswからコンパイルできます。
追加のインクルードとライブラリのディレクトリは、既定で
となっており、必要ならばこれを修正します。
| エラー内容 | 対処法 |
|---|---|
| math.h(565): error C2059: 構文エラー: '(' | jkFormatMP3.c の#define roundf(x) の定義がmath.hのそれと衝突するため、これの名前を変更する。 |
| LINK : fatal error LNK1104: ファイル 'tclstub84.lib' を開くことができません。 | Tcl\lib\tclstub**.libのファイル名を確認し、参照しているTclのバージョンに合うようにプロジェクトの[追加の依存ファイル]を修正する。 |
| jkSoundEngine.obj : error LNK2001: 外部シンボル "_Tcl_SeekOld" は未解決です。 | jkSound.h の#if TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION < 4 以降の処理によって、Tclのバージョンが8.4未満ではないと未定義の関数が割り当てられる。関数を定義するか、定義済みの関数を呼ぶように修正する。 |
| error LNK2001: 外部シンボル "_Tk_InitStubs" は未解決です。 | リンカーの[追加の依存ファイル]にtkstub84.libを追加する。 |
soundオブジェクトを生成できます。
snack::sound ?soundName? ?-load filename? ?-file filename? ?-channel channelname? ?-rate f? ?-channels n? ?-encoding fmt? ?-fileformat fmt? ?-skiphead n? ?-byteorder endianess? ?-guessproperties boolean? ?-buffersize n? ?-precision prec? ?-changecommand procedure? ?-debug level?snack::sound - Snack Manual
生成したsoundオブジェクトに対し、下表のコマンドを指示できます。
| コマンド | オプション |
|---|---|
| append | variable ?-rate f? ?-channels n? ?-encoding fmt? ?-skiphead n? ?-byteorder endianess? ?-start start? ?-end end? ?-fileformat fmt? ?-guessproperties boolean? |
| cget | option |
| changed | flag |
| concatenate | sound |
| configure | option value ... |
| convert | option value ... |
| copy | sound ?-start start? ?-end end? |
| crop | start end |
| cut | start end |
| data | ?variable? ?option value? ... |
| destro | |
| dBPowerSpectrum | ?-start sample? ?-end sample? ?-fftlength length? ?-windowlength length? ?-windowtype type? ?-skip samples? ?-channel channel? ?-preemphasisfactor factor? ?-analysistype type? ?-lpcorder n? |
| filter | filterName ?-start sample? ?-end sample? ?-continuedrain boolean? ?-progress callback? |
| flus | |
| formant | ?-start sample? ?-end sample? ?-framelength t? ?-numformants n? ?-windowlength length? ?-preemphasisfactor factor? ?-windowtype type? ?-lpctype? ?-lpcorder n? ?-ds_freq? ?-nom_f1_freq? ?-progress callback? |
| inf | |
| insert | sound position ?-start start? ?-end end? |
| lastInde | |
| length | ?n? ?-unit u? |
| max | ?-start start? ?-end end? ?-channel channel? |
| min | ?-start start? ?-end end? ?-channel channel? |
| mix | sound ?-start start? ?-end end? ?-mixscaling factor? ?-prescaling factor? ?-progress callback? |
| paus | |
| pitch | ?-method m? ?-start start? ?-end end? ?-framelength t? ?-windowlength length? ?-maxpitch val? ?-minpitch val? ?-progress callback? |
| play | ?-start start? ?-end end? ?-output jack??-blocking boolean? ?-command callback? ?-device outputDevice? ?-filter filter? ?-devicerate f? ?-devicechannels n? |
| power | ?-start sample? ?-end sample? ?-framelength length? ?-windowlength length? ?-windowtype type? ?-preemphasisfactor factor? ?-channel channel? ?-progress callback? |
| powerSpectrum | ?-start sample? ?-end sample? ?-fftlength length? ?-windowlength length? ?-windowtype type? ?-skip samples? ?-channel channel? ?-preemphasisfactor factor? ?-analysistype type? ?-lpcorder n? |
| read | filename ?-fileformat fmt? ?-rate f? ?-channels n? ?-encoding fmt? ?-skiphead n? ?-byteorder endianess? ?-start start? ?-end end? ?-guessproperties boolean? ?-progress callback? |
| record | ?option value? ... |
| reverse | ?-start start? ?-end end? ?-progress callback? |
| sample | n ?value? ... |
| speatures | sound ?-start start? ?-end end? ?-channel channel? ?-framelength length? ?-windowlength length? ?-preemphasisfactor factor? ?-windowtype type? ?-nchannels n? ?-ncoeff n? ?-cepstrallifter boolean? ?-energy boolean? ?-zeromean boolean? ?-zerothcepstralcoeff boolean? ?-lowcutoff freq? ?-highcutoff freq? |
| sto | |
| write | filename ?-start start? ?-end end? ?-fileformat fileformat? ?-byteorder endianess? ?-progress callback? |
filterオブジェクトを生成できます。
snack::filter type ?arg? ...snack::filter - Snack Manual
typeには、下表のフィルタ タイプを指定できます。
| type | arg |
|---|---|
| compose | filter filter ... |
| echo | inGain outGain delay decay ?delay decay ...? |
| fade | direction type length |
| formant | frequency bandwidth |
| generator | frequency ?amplitude? ?shape? ?type? ?ntot? |
| iir | ?-denominator list? ?-dither value? ?-impulse list? ?-noise value? ?-numerator list? |
| map | val ?val val val ...? |
| reverb | outGain time delay ?delay ...? |
(bin) 1 % package require snack 2.2 (bin) 2 % set s [snack::sound] sound1 (bin) 3 % set f [snack::filter generator 440.0 30000 0.0 sine 8000] generator1 (bin) 4 % $s play -filter $f
ピッチ (基本周波数) の推定に用いられています。基本周波数についてのまとめ - 備忘録