HE-AACはサンプルレートを半分で書く – LadioCast開発記その57

in LadioCast

Mac OS X 10.6 Snow Leopard の Core Audio には HE-AAC(別名AAC+)エンコーダーがつきました。OSがエンコーダーを標準で備えるということは、なるべくリーガルに事をやろうとするLadioCastのようなソフトウェアにとって非常に喜ばしいことです。

既にLadioCastのHE-AAC形式への対応実装は済みました。 今回はその際にはまったHE-AACの不思議な決まりについての話。

AACやHE-AACはストリーミング形式で送信する際ADTSという形式を使ったりします。 そこには他の情報とともに、そのエンコーディングがサンプルレートいくつで成されたものかを表記する仕様になっています。 最初AACの時と同じように素直にそのままサンプルレートをのせたのですが、どうしてもうまく再生されません。 結論からいうと、プレイヤーで正しく再生される HE-AAC on ADTS 形式の音声データは、用いたサンプルレートの半分の値を表記することになっているようです。

実際そのようにして生成させ正しく再生できたファイルを、音声形式を調べるコマンド afinfo を使って調べてみると、以下のように表示されます。

File type ID:   adts
Data format:     2 ch,  22050 Hz, 'aac ' (0x00000000) 0 bits/channel, 0 bytes/packet, 1024 frames/packet, 0 bytes/frame
・・・
format list:
[ 0] format:     2 ch,  44100 Hz, 'aach' (0x00000000) 0 bits/channel, 0 bytes/packet, 2048 frames/packet, 0 bytes/frame
Channel layout: Stereo (L R)
[ 1] format:     2 ch,  22050 Hz, 'aac ' (0x00000000) 0 bits/channel, 0 bytes/packet, 1024 frames/packet, 0 bytes/frame
Channel layout: Stereo (L R)
みるとHE-AAC形式は従来のAACの部分と拡張した部分とがきれいに分かれており、AACの部分のサンプルレートは元のサンプルレートの半分(22kHz)でエンコーディングされていることがわかります。 半分にすることで空いた領域に、拡張した分をこれは指定されたサンプルレート(44kHz)でエンコーディングして入れています。 そしてADTS上に表記するサンプルレートはAACの方である半分の値(22kHz)とする決まりのようです。

逆にプレイヤーWinampが以前から通常のAACのサンプルレートを高く誤表示するのも、ここらへんに理由があるのかもしれませんね。

14 Responses to “HE-AACはサンプルレートを半分で書く – LadioCast開発記その57”

  1. はじめまして。
    WinAmp+edcast+icecast2でどうやっても日本語がiTunes上(OSX/Winともに)やiPhoneアプリで文字化けしてしまうため彷徨っていたところたどり着きました。
    WinAmpでは日本語表示できたんですがその他のツールでことごとくNGだったため途方にくれていました。
    icecast2をUTF-8出力にしLadioCastからもUTF-8出力にすることによって念願の文字化けしない配信が可能となりほくほくしております。ありがとうございます。
    ただテスト中に一つ把握できないことがあたため伺いたく投稿させていただきました。
    HE-AAC対応とのことですが利用するにはエンコーディング項目のフォーマットをAACにすれば自動的にHE-AACによる配信になるのでしょうか?
    AAC+(HE-AAC)48kbpsで配信したいため、現在SnowLeopard iTunes9にてフォーマット:AAC、サンプルレート:自動、ビットレートモード:一定 48、チャンネル:Stereo に設定しています。
    iTunesやWinAmpでは問題なく受信できているのですが、一部のiPhoneアプリでて”Unrecognized stream type:audio/aac!”というエラーで出て受信することができませんでした。
    このアプリはAAC+対応済みでWinAmp+edcastからのHE-AAC配信は受信できていました(文字化けはしますが)
    LadioCastのフォーマットをMP3にすれば無事に受信できるため、本当にHE-AACで配信できているのかと気になっています。もしくはHE-AACにも何か微妙に違う規格が存在するのでしょうか?
    お手数をおかけしますが、何らかのアドバイスをいただければ幸いです。
    よろしくお願いします。

  2. かわうそ

    JUnさんこんにちは!
    かなりこの世界にはまってる方のようですね^^。
    え~LadioCastは次のリリース予定(0.9.0)からHE-AAC(Snow Leopard only)対応になります。これは現在のAAC形式とは別項目になります。
    Apple Core AudioのHE-AACがどれぐらいの音を出すものか、しばしお待ちくださいませ(たぶん来月中です)。

  3. 早速のレスポンスありがとうございます!
    なるほど、未対応でしたか。今でも十分に音がよいのでさすがHE-AACなのか?
    と素で思っておりました(笑)
    来月対応バージョンが出るとのこと。
    楽しみにしています!がんばってください。

  4. Hello again!
    I just wanted to let you know that I FINALLY figured out why I could not get Ladio to stream to Weather Underground! I had put my user name in the USER field of your program! The field where you have “source” when the program is first launched. I was trying all kinds of different changes trying to get it to work, and when I deleted my user name from that field and left it blank BINGO! LadioCast immediately connected without the previous LOGIN ERROR mesage and now it is happily streaming my NOAA Weather Radio broadcast for our area to the WU servers. (Fresno Ca. feed)
    http://www.wunderground.com/wxradio/index.html
    So far your little program is working like a charm!
    My only question now is if you have any plans to expand the features of the application to include some EQ? These weather radio stations are a bit on the weak side and it is nearly impossible to get a signal that is free of high freq. hiss and static. If LadioCast had an adjustable EQ built in, I could dial some of that top end hiss out and improve the audio quality of my stream.
    Is adding EQ something that you may be considering for future builds?
    IF that was added, this program would be complete! I have already emailed Wunderground about my breakthrough with your application and there is a very good chance that they will soon be including Macintosh support in their streaming radio FAQ section. This will of course include a link to LadioCast along with the setup procedure that I have performed that resulted in a successful stream to their servers!
    Please reply via email if possible, or provide me with your comments here. Either way would be great!
    Thanks again for providing such a useful program and offering it for FREE! PRetty amazing! :o)
    Cheers.
    []Rick.
    Bass Lake Ca.

  5. はじめまして。
    ライブ配信を行っている者ですが、ladiocastはオーディオミキサーソフトとして重宝させていただいています。
    AU Labなどもいいのですが、ladiocastの直感的なインターフェイスは非常に使いやすいです。
    見かけや操作なども非常に気に入っているのですが、一つだけ今後の追加機能としてお願いできないでしょうか。
    と言いますのが、私が現在使っている環境の解像度が低く、ladiocastを起動すると画面の半分が隠れてしまいます。
    そこで、右側のストリーミング部分をドロワー表示や、左とは別に表示できたら更に便利になるのではないかと思いました。
    もしくは単純にウィンドウサイズを調節出来る様な形でも非常に助かります。
    今では、Macで手軽に使えるオーディオミキサーと言えば誰もがladiocastの名前をあげると思います。
    忙しい事とは思いますが、よろしければご検討いただけますでしょうか。
    これからも応援しています。

  6. kawauso

    Hello, Rick!
    Sorry for the tardy response, and that there seems to be previous inquiry about the settings of LadioCast.
    Anyway, thank you for your helpful information about that to connect the NOAA Weather Radio broadcast server.
    Then EQ, is surely an interesting issue for such kind of application, and actually it’s not very hard to implement with the framework of Apple Core Audio. Though, I think the application should be still concentrated on its own audio quality right now. So it’s in future plans.
    Happy broadcasting, C U!

  7. かわうそ

    kenさんこんにちは!
    LadioCast気に入られているようでなによりです。
    奇遇ですが^^;次のリリース0.9系列ではミキサー部とストリーミング部が独立のウィンドウになる予定です。ミキサー部の方がLadioCastの主ということになるでしょうね。表示領域はどうかな、まあ見てのお楽しみです。
    予告ばかりするのもなんですが、いつもやる古めマシンでのテストがうまくいけば11月の頭でのリリースじゃないかな、と思います。
    ではでは。

  8. Thanks for the reply C U! :o)
    I understand your desire to hone the current audio quality aspects of LadioCast, but I have to tell you… It already surpasses NiceCast! I did a side by side comparison between the two because NiceCast already has EQ capabilities built in, but I definitely heard a lot of artifacts on the final broadcast on WU with that than I do with LadioCast! Your program delivers a very natural sounding audio stream that sounds pretty much identical to the actual radio audio being fed into my Mac! I listened to about a dozen other NOAA streams on WU comparing my audio quality to all of the WIndows based streams and guess what?
    LADIOCAST WAS HANDS DOWN THE BEST!! I am not just saying that because I will always go with what does the best job, even if I had to pay for it! I was pleased that in this case YOUR FREE application dominated your competition!
    As far as the EQ goes… I have solved that problem to a large degree by placing a 9 band graphic EQ inline between my radio output and my Mac’s input. I am able to pull a good deal of the hiss out using this little piece of audio hardware, but if you ever do add EQ plug-in capability to LadioCast I could use both of these together to get an even clearer signal going out to WU! :o)
    I do have another feature request that I hope you can add to the next release…
    Could you add a “CONNECT ON LAUNCH” option to LadioCast? My system is 100% automated, and I need to power cycle my internet gear a few times per week. When this occurs, I need to quit LadioCast until the internet is back up. It would be great if all I had to do with Automator was to launch LadioCast and let it automatically connect to WU when it comes up!
    Right now, I have to use an Automator action that involves a mouse over and CLICK, and for some reason, this does not always work properly, resulting in LadioCast launching, but just sitting there from 3AM until I get up and realize that it once again did not connect on its own!
    Hope that it would be an easy thing to add. That was one of the feaures of NiceCast that appealed to me besides the EQ thing, but as I said… LadioCast sounds MUCH MUCH BETTER, so I am sticking with it! :o)
    Thanks in advance for your comments and hopefully your decision to add CONNECT ON LAUNCH to the next release!
    Cheers.
    []Rick.

  9. Oh! I forgot to also request this…
    Is there any way you can add something to LadioCast that can re-establish the connection to the server if the server drops the connection? I have seen this happen a few times where the WU server goes offline for some reason, and with the current version, it requires human input to reconnect LadioCast. Otherwise, it just sits there with no explanation of what happened.
    If you could put some kind of retry system in there that the user can set to keep trying to re-establish the connection, that would be WONDERFUL! Between this and the CONNECT ON LAUNCH, I would be able to let my machine go unattended with very little risk of downtime!
    Thanks again!
    Cheers.
    []Rick.

  10. kawauso

    Hello again, Rick!
    Thank you for your support and suggestion. On 0.9 releases, I would add some little (AppleScript) interface to operate connectivity of LadioCast. I hope it helps, and further suggestions welcome.
    Cheers!

  11. Thanks for the reply Kawauso! :o)
    That sounds great to me! You think you can add both the CONNECT ON LAUNCH and a RETRY system?
    NIceCast provides a check box in the preferences called “CONNECT ON LAUNCH” and when checked, the program automatically connects to the server when it boots up, which saves the user from having to manually connect the application to the server. It also will reconnect automatically if the connection gets dropped for whatever reason.
    With this same feature in LadioCast, I could dispense with the Automator action I am currently trying to use that mouses over the connect button and click it, to initiate the connection. If you add this auto connect option, all I need to do is auto-launch LadioCast on startup or on a schedule, and LadioCast will handle the actual connection start. :o)
    Looking forward to the next release very much!
    Cheers.
    []Rick.

  12. Thanks! :o)
    I got 0.9 and was able to get the CONNECT script to work perfectly! :o) Thanks SO MUCH for adding that!
    However, I don’t see anything in there to make LadioCast RETRY the connection if it gets dropped. Did I miss something?
    I saw this script command:
    tell application “LadioCast” to open “/Users/kawauso/Desktop/foo.plist”
    What does this do, and where would I find “foo.plist” on my machine?
    Oh! And don’t forget to update your vesion on Apple.com
    http://www.apple.com/downloads/macosx/audio/ladiocast.html
    Take care!
    []Rick.

Leave a Reply to JUn

Click here to cancel reply.

*