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@7:6d921f8c38d6, 2017-01-27 (annotated)
- Committer:
- shorie
- Date:
- Fri Jan 27 21:08:29 2017 +0000
- Revision:
- 7:6d921f8c38d6
- Parent:
- 5:bbbf6cd235d4
Doxygen comment update
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
shorie | 5:bbbf6cd235d4 | 1 | /** |
shorie | 7:6d921f8c38d6 | 2 | * \ file baseaudiocodec.h |
shorie | 2:fba0b8afebf0 | 3 | * \brief header file for an abstract audio codec class |
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 | 2:fba0b8afebf0 | 15 | namespace shimabara |
shorie | 1:ea6d442bd68a | 16 | { |
shorie | 1:ea6d442bd68a | 17 | |
shorie | 1:ea6d442bd68a | 18 | |
shorie | 5:bbbf6cd235d4 | 19 | /** |
shorie | 5:bbbf6cd235d4 | 20 | * \brief Sampling Frequency of the umb_adau1361 |
shorie | 5:bbbf6cd235d4 | 21 | */ |
shorie | 1:ea6d442bd68a | 22 | enum Fs_Type |
shorie | 1:ea6d442bd68a | 23 | { |
shorie | 5:bbbf6cd235d4 | 24 | Fs_32, ///< 32kHz |
shorie | 5:bbbf6cd235d4 | 25 | Fs_441, ///< 44.1kHz |
shorie | 5:bbbf6cd235d4 | 26 | Fs_48, ///< 48kHz |
shorie | 5:bbbf6cd235d4 | 27 | Fs_96 ///< 96kHz |
shorie | 1:ea6d442bd68a | 28 | } ; |
shorie | 1:ea6d442bd68a | 29 | |
shorie | 1:ea6d442bd68a | 30 | |
shorie | 1:ea6d442bd68a | 31 | /** |
shorie | 1:ea6d442bd68a | 32 | * \brief abstract audio codec controller. |
shorie | 1:ea6d442bd68a | 33 | * \details |
shorie | 1:ea6d442bd68a | 34 | * This class is template for all codec classes |
shorie | 1:ea6d442bd68a | 35 | */ |
shorie | 1:ea6d442bd68a | 36 | class BaseAudioCodec |
shorie | 1:ea6d442bd68a | 37 | { |
shorie | 1:ea6d442bd68a | 38 | public: |
shorie | 1:ea6d442bd68a | 39 | /** |
shorie | 1:ea6d442bd68a | 40 | * \brief constructor. |
shorie | 1:ea6d442bd68a | 41 | * \param Fs Sampling frequency. |
shorie | 1:ea6d442bd68a | 42 | * \param Addr I2C device address. value range is from 0 to 127 |
shorie | 1:ea6d442bd68a | 43 | * \details |
shorie | 1:ea6d442bd68a | 44 | * initialize the internal variables. |
shorie | 1:ea6d442bd68a | 45 | */ |
shorie | 2:fba0b8afebf0 | 46 | BaseAudioCodec( Fs_Type Fs ); |
shorie | 1:ea6d442bd68a | 47 | |
shorie | 1:ea6d442bd68a | 48 | /** |
shorie | 1:ea6d442bd68a | 49 | * \brief Actual initializer. |
shorie | 1:ea6d442bd68a | 50 | * \details |
shorie | 1:ea6d442bd68a | 51 | * Initialize the codec itself and start the conversion process. |
shorie | 1:ea6d442bd68a | 52 | * and configure for given parameter. |
shorie | 1:ea6d442bd68a | 53 | * |
shorie | 1:ea6d442bd68a | 54 | * Finally, set the input gain to 0dB. |
shorie | 1:ea6d442bd68a | 55 | */ |
shorie | 1:ea6d442bd68a | 56 | virtual void start(void)=0; |
shorie | 1:ea6d442bd68a | 57 | |
shorie | 1:ea6d442bd68a | 58 | /** |
shorie | 1:ea6d442bd68a | 59 | * \brief Set the line input gain and enable the relevant mixer. |
shorie | 1:ea6d442bd68a | 60 | * \param left_gain Gain by dB. The gain value outside of the acceptable range will be saturated. |
shorie | 1:ea6d442bd68a | 61 | * \param right_gain Gain by dB. The gain value outside of the acceptable range will be saturated. |
shorie | 1:ea6d442bd68a | 62 | * \param mute set true to mute |
shorie | 1:ea6d442bd68a | 63 | */ |
shorie | 1:ea6d442bd68a | 64 | virtual void set_line_input_gain(float left_gain, float right_gain, bool mute=false); |
shorie | 1:ea6d442bd68a | 65 | /** |
shorie | 1:ea6d442bd68a | 66 | * \brief Set the aux input gain and enable the relevant mixer. |
shorie | 1:ea6d442bd68a | 67 | * \param left_gain Gain by dB. The gain value outside of the acceptable range will be saturated. |
shorie | 1:ea6d442bd68a | 68 | * \param right_gain Gain by dB. The gain value outside of the acceptable range will be saturated. |
shorie | 1:ea6d442bd68a | 69 | * \param mute set true to mute |
shorie | 1:ea6d442bd68a | 70 | */ |
shorie | 1:ea6d442bd68a | 71 | virtual void set_aux_input_gain(float left_gain, float right_gain, bool mute=false); |
shorie | 1:ea6d442bd68a | 72 | /** |
shorie | 1:ea6d442bd68a | 73 | * \brief Set the mic input gain and enable the relevant mixer. |
shorie | 1:ea6d442bd68a | 74 | * \param left_gain Gain by dB. The gain value outside of the acceptable range will be saturated. |
shorie | 1:ea6d442bd68a | 75 | * \param right_gain Gain by dB. The gain value outside of the acceptable range will be saturated. |
shorie | 1:ea6d442bd68a | 76 | * \param mute set true to mute |
shorie | 1:ea6d442bd68a | 77 | */ |
shorie | 1:ea6d442bd68a | 78 | virtual void set_mic_input_gain(float left_gain, float right_gain, bool mute=false); |
shorie | 1:ea6d442bd68a | 79 | /** |
shorie | 1:ea6d442bd68a | 80 | * \brief Set the line output gain and enable the relevant mixer. |
shorie | 1:ea6d442bd68a | 81 | * \param left_gain Gain by dB. The gain value outside of the acceptable range will be saturated. |
shorie | 1:ea6d442bd68a | 82 | * \param right_gain Gain by dB. The gain value outside of the acceptable range will be saturated. |
shorie | 1:ea6d442bd68a | 83 | * \param mute set true to mute |
shorie | 1:ea6d442bd68a | 84 | */ |
shorie | 1:ea6d442bd68a | 85 | virtual void set_line_output_gain(float left_gain, float right_gain, bool mute=false); |
shorie | 1:ea6d442bd68a | 86 | /** |
shorie | 1:ea6d442bd68a | 87 | * \brief Set the headphone output gain and enable the relevant mixer. |
shorie | 1:ea6d442bd68a | 88 | * \param left_gain Gain by dB. The gain value outside of the acceptable range will be saturated. |
shorie | 1:ea6d442bd68a | 89 | * \param right_gain Gain by dB. The gain value outside of the acceptable range will be saturated. |
shorie | 1:ea6d442bd68a | 90 | * \param mute set true to mute |
shorie | 1:ea6d442bd68a | 91 | */ |
shorie | 1:ea6d442bd68a | 92 | virtual void set_hp_output_gain(float left_gain, float right_gain, bool mute=false); |
shorie | 1:ea6d442bd68a | 93 | protected: |
shorie | 1:ea6d442bd68a | 94 | unsigned int addr; |
shorie | 1:ea6d442bd68a | 95 | Fs_Type fs; |
shorie | 1:ea6d442bd68a | 96 | }; |
shorie | 1:ea6d442bd68a | 97 | |
shorie | 1:ea6d442bd68a | 98 | |
shorie | 1:ea6d442bd68a | 99 | } |
shorie | 1:ea6d442bd68a | 100 | |
shorie | 1:ea6d442bd68a | 101 | #endif |