2015年7月27日月曜日

Raspberry Phys を MFT2015 で展示します

Maker Faire Tokyo 2015(8/1〜2@東京ビッグサイト) で、物理モデル音源モジュール『Raspberry Phys』を展示します

8/1 から開催される、Maker Faire Tokyo 2015 にて、奇楽堂のサポートメンバーとして、Raspberry Pi 2 をベースに製作した物理モデル音源モジュール『Raspberry Phys(ラズベリーフィズ)』を出展します。

奇楽堂さんは、電子楽器を製作する個人プロジェクトです。今回、奇楽堂さんが開発した、電子吹奏楽器『Magic Flute』向けに、音源モジュール Raspberry Phys を開発しました。Magic Flute は、親指と小指を除いた 6 本の指を使い、3 オクターブの音域を演奏できる電子吹奏楽器です。Raspberry Phys は、オープンソースの音響処理ライブラリ STK (The Synthesis ToolKit) をベースに、Magic Flute 向けの音色を組み込んだ音源モジュールです。音源システムとして、物理モデル音源を用いました。物理モデル音源は、楽器の発音構造をモデル化し、コンピュータシミュレーションで発音する音源システムで、90 年代にはヤマハやコルグから、同音源システムを採用したシンセサイザが販売されていました。

物理モデル音源を Magic Flute を組み合わせると、吹奏圧を発音パラメータとして利用できるため、豊かな音色変化が得られます。ぜひ、Maker Faire Tokyo 2015 の奇楽堂ブース(C-02-04) にお越しいただき、その音色をお聴きください。

なお、Raspberry Phys は、販売も、頒布も、予定しておりません。前述の STK を用いると、どなたでも簡単に、物理モデル音源を試せますので、ぜひチャレンジしてください。Raspberry Pi で STK を動作させる方法を、以前 Qiita に書きましたので、あわせてご参考ください。

ところで、その筋の方(?) 向けにあらかじめ断っておきますが、Raspberry Phys は、「生楽器のようにリアル」な発音はできませんし、90 年代当時にヤマハが開発した物理モデル音源システムとは比べ物にならないほど安っぽい出音です。とはいえ、5,000円の CPU ボードとフリーソフトウェアでここまで遊べる時代、すばらしいですね。




製作中の様子:16x2 のキャラクタ LCD とスイッチx2 への配線をしています



2015年4月28日火曜日

Web MIDI Browser 1.0.5: 最新の Web MIDI API をサポート

Web MIDI Browser 1.0.5: 最新の Web MIDI API をサポート

Web MIDI Browser の 1.0.5 で、Web MIDI API の最新ドラフト (17 March 2015) 日本語版)で規定された API を提供するようになりました。この版のハイライトは、なんと言ってもホットプラグ対応です。ブラウザ内で Web アプリが動作している状態で、iOS デバイスへMIDI 機器が接続された場合に、Web アプリは通知を受けられるようになります。この機能により、Web アプリの操作性を、ネイティブアプリに近づけられるはずです。中で使っている WebMIDIAPIShimForiOS も更新しました。

実は、まだ仕様に完全対応とは言えず、現在の Wrapper の設計と相容れない部分があって、未実装になっている仕様があります。onstatechange や、state,  connection など、主要なインターフェイスは Chorme 43 Beta にそっくりにしてあります。してあるはずです。なっていなかったらごめんなさい。(間違っているところを見つけたらこっそり教えてください)



2015年4月20日月曜日

Web MIDI Browser 1.0.4: Apple Watch support

Web MIDI Browser 1.0.4: Apple Watch support

Web MIDI Browser 1.0.4 has been released. This version includes some bug fixes and Watch App extension. I don't know whether or not it's suitable as a Watch App. But we, Apple fans, must join the festival... right?

It's easy to use. You can enable "Enable Apple Watch Remote" option in the setting pane of the app. Then, a virtual MIDI port will appear. By pressing the button on Apple Watch, control change messages can be obtained from the virtual port. And then, cook them as you like. The function is available on iPhone 5/5s/5c/6/6Plus.


Watch Kit is a simple framework and has many restrictions. The button control, WKInterfaceButton, can observe Touch Up event only. So, I could NOT implement a control like a musical keyboard, sending noteon by touching-down, sending noteoff by touching-up. I really hope that it will get more controllable APIs in iOS 9... please, Apple guys.

And I fixed some bugs in this version. The next version, 1.0.5, will support the latest Web MIDI API, Chrome 43 spec, which includes the hot-plugging functionality. The polyfill library, WebMIDIAPIShimForiOS, is available on GitHub. It will be updated. Enjoy!

Web MIDI Browser 1.0.4 をリリースしました。このバージョンでは、バグ修正のほか、Apple Watch への対応を行いました。Apple Watch のアプリとして実用的かどうかはわかりませんが、お祭りなので。

使い方は簡単です。設定画面から"Enable Apple Watch Remote" を有効にすると、ブラウザ内で動作する Web アプリから仮想の MIDI Input Port が見えるようになります。そして、Apple Watch 上に現れるボタンを押すと、コントロールチェンジ ("0xb0 0x51 0x7f" 〜 "0xb0 0x54 0x7f") を送信します。あとは皆さんのアイデア次第。いろいろ遊んでみてください。この機能は、iPhone 5/5s/5c/6/6Plus で使えます。

iOS 8 の Watch Kit でできることは限られていて、このアプリでも使っている標準コントロールのボタン (Watch Extension 的には WKInterfaceButton) は、Touch Up (押したあと、離した時にイベント発生)しか検知できません。そのため、音楽アプリで使う鍵盤のように、押して Note On、離して Note Off を送信することはできないようでした。もう少し細かい制御ができれば、アプリの作り甲斐があるのですが。6 月に発表される iOS 9 に期待しています。

そのほか、いくつかのバグもあわせて修正しています。

今後ですが、次のバージョン (1.0.5) で、最新の Web MIDI API への対応を予定しています。今実装してあるのは少し古い Chrome 39 spec で、次のバージョンで Hotplug にも対応した Chrome 43 spec に合わせる予定です。中で使っている Web MIDI API の Polyfill は、WebMIDIAPIShimForiOS として GitHub で公開しています。こちらもあわせて更新されます。



2015年2月15日日曜日

Trying Gracenote API

Trying Gracenote API



My wife has tons of MD (mini disk). MD was a major medium for portable music player in '90s Japan. Unfortunately, it was killed by iPod. MD mediums and MD players no longer be able to buy nowadays. Therefore, she wanted to migrate songs from her MDs to iTunes library before her player breaks.

To help her, I bought a Behringer's USB Audio interface and connected her dated MD player. And I recorded whole tracks of the MDs through Audacity. Audacity has a function to split the recorded audio into multiple audio files by certain length of silences. The accuracy is so so. I needed to remove wrong split points sometimes. Anyway, the things worked well so far.

But, of course, these audio files have no name. It's a big deal nowadays. Because the song name is the ONLY identifier for selecting a song in iTunes library. But setting song name manually for all taped audio tracks is a heavy work... So, I tried Gracenote API to set song title into ID3 tag automatically. We can use Gracenote API for free of charge in non-commercial use.

I made a program for querying song title through Gracenote API. It's remodeled from a sample program in GNSDK. It can print a title string by querying fingerprint of the audio file which is designated in command line argument. I also made a simple shell script to rewrite ID3 tag from the output of the title query tool. I used id3v2 for editing ID3 tag. The accuracy of song name detection is slightly better than I expected. Anyway, it's really better than "no name". 

So, I could help her in return for chocolates her gave me today. (I wrote this article on 14th Feb)



2015年2月9日月曜日

DXi FM synth supports Bluetooth MIDI



DXi FM synthesizer version 3.8.0 is out. It supports Bluetooth MIDI instruments, e.g. Miselu C.24. Enjoy!

DXi FM synthesizer のバージョン 3.8.0 がリリースされ、Bluetooth MIDI 機器(Miselu の C.24 など)をサポートしました!お試しください。


2015年1月31日土曜日

Web MIDI Browser 1.0.1


Web MIDI Browser has been updated to 1.0.1. This new version includes an “Action Extension”. The Action Extension will let you launch the app from Action Menu in Mobile Safari. And then, Web MIDI Browser will automatically open the URL which is being opened in Safari at the time. The app’s functionalities are not enough for usual web browsing. So, I suggest
  • Use Safari in usual
  • Use Web MIDI Browser for web sites using Web MIDI API (You can smoothly launch the app from Action Menu)
And a small bug was fixed. Enjoy!

Web MIDI Browser のバージョン 1.0.1 をリリースしました。このバージョンには、”Action Extension” が同梱されています。Action Extension を使うと、iOS 標準のブラウザ Safari のアクションメニューから、このアプリを起動することができます。この時、Safari が開いている URL を自動的に開いてくれます。Web MIDI Browser のブラウザとしての機能は貧弱です。そのため、
  • 普段のウェブブラウズはもちろん Safari で
  • Web MIDI API を使ったサイト開くときだけアクションメニューから Web MIDI Browser にスイッチする
という使い方が良いと思います。

また、このバージョンで、小さなバグを直しました。
ご要望などあればぜひお知らせください。



2015年1月8日木曜日

iOS 8 Safari Action Extension でハマる - 解決編

iOS 8 Safari Action Extension でハマる - 解決編

先日の記事で、iOS 8 Safari Action Extension から、URL Scheme を使ったアプリ起動に失敗した件、結局解決できたので追記。

non-UI Extension 用に用意されている JavaScript アダプタ内で location.href を書き換え

Action Extension には、UIを提供するタイプ("Presents User Interface") のものと、UIを提供しないもの("No User Interface") の 2 種類がある。後者の場合、Safari から Extension が
起動されたときに、Extension にバンドルされた JavaScript がロードされるようになっている。この JavaScript では、Pre 処理と Post 処理を記述できるようになっている。Pre 処理 (ExtensionPreprocessingJS.run 関数)で、DOM から必要な要素をピックアップし、Native 側に渡す。で、Native 側で必要な処理を行い、Post 処理(ExtensionPreprocessingJS.finalize)に渡して DOM へ変更を反映するという設計思想。
この Post 処理の中で、location.href を変更すれば、Safari が URL scheme をキックしてくれるので、マッチした URL scheme が登録されているアプリを起動できる。

実装方法

JavaScript を Action.js として Extension にバンドルする。

Safari の Action Menu を開き、作成した Extension のアイコンをタップすると、-(void)beginRequestWithExtensionContext: が呼びだされる。Native 側では特になにもせず、completion handler を呼びだすだけ。ただ、completeRequestReturningItems に、適当なパラメータを渡してやらないと、なぜか、ExtensionPreprocessingJS.finalize() が呼ばれなかった。

もうちょっとシンプルな方法がありそうだけど、ひとまず目的は達成。あとで内容を整理して、Qiita に投稿する→投稿した