First publishment of Shimabara Audio Codec Controller library. Including code for ADAU1361 and UMB-ADAU1361A. Working pretty fine. Checked with LPCXpresso 4337 and Unzen_lpc4337
Dependents: unzen_sample_LPC4088_quickstart unzen_sample_lpcxpresso_4337_callbacks unzen_sample_nucleo_f746 unzen_delay_sample_nucleo_f746 ... more
shimabaraは、mbedからオーディオ・コーデックのハードウェアを操作するクラス・ライブラリです。このライブラリは雲仙オーディオ・フレームワークと共に使うことを想定して開発しましたが、独立して使うことも可能です。
使い方
shimabaraは BaseAudioCodec, ADAU1361, UMB_ADAU1361Aの三つのクラスを定義しています。いずれのクラスも名前空間simabaraに属しています。実際のアプリケーションで使用するのはshimabara::UMB_ADAU1361Aだけで、このクラスはアクアシグナルのUMB-ADAU1361-Aに対応しています。ヘッダーファイルは umb_adau1361a.hです。
shimabara::UMB_ADAU1361Aのコンストラクタは三つの引数を受け取ります。
- Fs はサンプル周波数です。これはenum Fs_type型の引数で、やはり名前空間shimabaraに属しています。
- controller はADAU1361Aが接続されているI2Cポートに対応するI2Cオブジェクトを与えます。shimabaraはこのポートを通してCODECと通信します。
- Addrには、コーデックのI2Cアドレスを与えます。現時点ではこの引数は0x38固定です。
コンストラクタでオブジェクトを初期化したら、start()メソッドを呼んでください。これでshimabaraはコーデックと通信し、I2Sモードでの動作が始まります。
参考リンク
- 『雲仙』 オーディオ・フレームワーク
- skeleton_unzen_nucleo_f746 Nucleo F746ZGおよびUI基板を使う場合のスケルトンプログラム。F746を使う方はここから読み始めると良いでしょう。
baseaudiocodec.h@1:ea6d442bd68a, 2016-05-08 (annotated)
- Committer:
- shorie
- Date:
- Sun May 08 09:52:42 2016 +0000
- Revision:
- 1:ea6d442bd68a
- Child:
- 2:fba0b8afebf0
Refactored naming conventions
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
shorie | 1:ea6d442bd68a | 1 | /** |
shorie | 1:ea6d442bd68a | 2 | * \file BaseAudioCodec.h |
shorie | 1:ea6d442bd68a | 3 | * \brief header file for the unzen audio frame work |
shorie | 1:ea6d442bd68a | 4 | * \arthur SeiichiHorie |
shorie | 1:ea6d442bd68a | 5 | * \date 6/Apr/2016 |
shorie | 1:ea6d442bd68a | 6 | */ |
shorie | 1:ea6d442bd68a | 7 | |
shorie | 1:ea6d442bd68a | 8 | #ifndef _BaseAudioCodec_h_ |
shorie | 1:ea6d442bd68a | 9 | #define _BaseAudioCodec_h_ |
shorie | 1:ea6d442bd68a | 10 | |
shorie | 1:ea6d442bd68a | 11 | #include "mbed.h" |
shorie | 1:ea6d442bd68a | 12 | /** |
shorie | 1:ea6d442bd68a | 13 | \brief audio framework name space. |
shorie | 1:ea6d442bd68a | 14 | */ |
shorie | 1:ea6d442bd68a | 15 | namespace audiocodec |
shorie | 1:ea6d442bd68a | 16 | { |
shorie | 1:ea6d442bd68a | 17 | |
shorie | 1:ea6d442bd68a | 18 | |
shorie | 1:ea6d442bd68a | 19 | // Sampling Frequency of the umb_adau1361 |
shorie | 1:ea6d442bd68a | 20 | enum Fs_Type |
shorie | 1:ea6d442bd68a | 21 | { |
shorie | 1:ea6d442bd68a | 22 | Fs_32, Fs_441, Fs_48, Fs_96 |
shorie | 1:ea6d442bd68a | 23 | } ; |
shorie | 1:ea6d442bd68a | 24 | |
shorie | 1:ea6d442bd68a | 25 | |
shorie | 1:ea6d442bd68a | 26 | /** |
shorie | 1:ea6d442bd68a | 27 | * \brief abstract audio codec controller. |
shorie | 1:ea6d442bd68a | 28 | * \details |
shorie | 1:ea6d442bd68a | 29 | * This class is template for all codec classes |
shorie | 1:ea6d442bd68a | 30 | */ |
shorie | 1:ea6d442bd68a | 31 | class BaseAudioCodec |
shorie | 1:ea6d442bd68a | 32 | { |
shorie | 1:ea6d442bd68a | 33 | public: |
shorie | 1:ea6d442bd68a | 34 | /** |
shorie | 1:ea6d442bd68a | 35 | * \brief constructor. |
shorie | 1:ea6d442bd68a | 36 | * \param controler Pass the I2C controler object. |
shorie | 1:ea6d442bd68a | 37 | * \param Fs Sampling frequency. |
shorie | 1:ea6d442bd68a | 38 | * \param Addr I2C device address. value range is from 0 to 127 |
shorie | 1:ea6d442bd68a | 39 | * \details |
shorie | 1:ea6d442bd68a | 40 | * initialize the internal variables. |
shorie | 1:ea6d442bd68a | 41 | */ |
shorie | 1:ea6d442bd68a | 42 | BaseAudioCodec( I2C * controler, Fs_Type Fs, unsigned int Addr ); |
shorie | 1:ea6d442bd68a | 43 | |
shorie | 1:ea6d442bd68a | 44 | /** |
shorie | 1:ea6d442bd68a | 45 | * \brief Actual initializer. |
shorie | 1:ea6d442bd68a | 46 | * \details |
shorie | 1:ea6d442bd68a | 47 | * Initialize the codec itself and start the conversion process. |
shorie | 1:ea6d442bd68a | 48 | * and configure for given parameter. |
shorie | 1:ea6d442bd68a | 49 | * |
shorie | 1:ea6d442bd68a | 50 | * Finally, set the input gain to 0dB. |
shorie | 1:ea6d442bd68a | 51 | */ |
shorie | 1:ea6d442bd68a | 52 | virtual void start(void)=0; |
shorie | 1:ea6d442bd68a | 53 | |
shorie | 1:ea6d442bd68a | 54 | /** |
shorie | 1:ea6d442bd68a | 55 | * \brief Set the line input gain and enable the relevant mixer. |
shorie | 1:ea6d442bd68a | 56 | * \param left_gain Gain by dB. The gain value outside of the acceptable range will be saturated. |
shorie | 1:ea6d442bd68a | 57 | * \param right_gain Gain by dB. The gain value outside of the acceptable range will be saturated. |
shorie | 1:ea6d442bd68a | 58 | * \param mute set true to mute |
shorie | 1:ea6d442bd68a | 59 | */ |
shorie | 1:ea6d442bd68a | 60 | virtual void set_line_input_gain(float left_gain, float right_gain, bool mute=false); |
shorie | 1:ea6d442bd68a | 61 | /** |
shorie | 1:ea6d442bd68a | 62 | * \brief Set the aux input gain and enable the relevant mixer. |
shorie | 1:ea6d442bd68a | 63 | * \param left_gain Gain by dB. The gain value outside of the acceptable range will be saturated. |
shorie | 1:ea6d442bd68a | 64 | * \param right_gain Gain by dB. The gain value outside of the acceptable range will be saturated. |
shorie | 1:ea6d442bd68a | 65 | * \param mute set true to mute |
shorie | 1:ea6d442bd68a | 66 | */ |
shorie | 1:ea6d442bd68a | 67 | virtual void set_aux_input_gain(float left_gain, float right_gain, bool mute=false); |
shorie | 1:ea6d442bd68a | 68 | /** |
shorie | 1:ea6d442bd68a | 69 | * \brief Set the mic input gain and enable the relevant mixer. |
shorie | 1:ea6d442bd68a | 70 | * \param left_gain Gain by dB. The gain value outside of the acceptable range will be saturated. |
shorie | 1:ea6d442bd68a | 71 | * \param right_gain Gain by dB. The gain value outside of the acceptable range will be saturated. |
shorie | 1:ea6d442bd68a | 72 | * \param mute set true to mute |
shorie | 1:ea6d442bd68a | 73 | */ |
shorie | 1:ea6d442bd68a | 74 | virtual void set_mic_input_gain(float left_gain, float right_gain, bool mute=false); |
shorie | 1:ea6d442bd68a | 75 | /** |
shorie | 1:ea6d442bd68a | 76 | * \brief Set the line output gain and enable the relevant mixer. |
shorie | 1:ea6d442bd68a | 77 | * \param left_gain Gain by dB. The gain value outside of the acceptable range will be saturated. |
shorie | 1:ea6d442bd68a | 78 | * \param right_gain Gain by dB. The gain value outside of the acceptable range will be saturated. |
shorie | 1:ea6d442bd68a | 79 | * \param mute set true to mute |
shorie | 1:ea6d442bd68a | 80 | */ |
shorie | 1:ea6d442bd68a | 81 | virtual void set_line_output_gain(float left_gain, float right_gain, bool mute=false); |
shorie | 1:ea6d442bd68a | 82 | /** |
shorie | 1:ea6d442bd68a | 83 | * \brief Set the headphone output gain and enable the relevant mixer. |
shorie | 1:ea6d442bd68a | 84 | * \param left_gain Gain by dB. The gain value outside of the acceptable range will be saturated. |
shorie | 1:ea6d442bd68a | 85 | * \param right_gain Gain by dB. The gain value outside of the acceptable range will be saturated. |
shorie | 1:ea6d442bd68a | 86 | * \param mute set true to mute |
shorie | 1:ea6d442bd68a | 87 | */ |
shorie | 1:ea6d442bd68a | 88 | virtual void set_hp_output_gain(float left_gain, float right_gain, bool mute=false); |
shorie | 1:ea6d442bd68a | 89 | protected: |
shorie | 1:ea6d442bd68a | 90 | I2C *i2c; |
shorie | 1:ea6d442bd68a | 91 | unsigned int addr; |
shorie | 1:ea6d442bd68a | 92 | Fs_Type fs; |
shorie | 1:ea6d442bd68a | 93 | }; |
shorie | 1:ea6d442bd68a | 94 | |
shorie | 1:ea6d442bd68a | 95 | |
shorie | 1:ea6d442bd68a | 96 | } |
shorie | 1:ea6d442bd68a | 97 | |
shorie | 1:ea6d442bd68a | 98 | #endif |