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
- Committer:
- shorie
- Date:
- 2017-01-27
- Revision:
- 7:6d921f8c38d6
- Parent:
- 5:bbbf6cd235d4
File content as of revision 7:6d921f8c38d6:
/** * \ file baseaudiocodec.h * \brief header file for an abstract audio codec class * \arthur SeiichiHorie * \date 6/Apr/2016 */ #ifndef _BaseAudioCodec_h_ #define _BaseAudioCodec_h_ #include "mbed.h" /** \brief audio framework name space. */ namespace shimabara { /** * \brief Sampling Frequency of the umb_adau1361 */ enum Fs_Type { Fs_32, ///< 32kHz Fs_441, ///< 44.1kHz Fs_48, ///< 48kHz Fs_96 ///< 96kHz } ; /** * \brief abstract audio codec controller. * \details * This class is template for all codec classes */ class BaseAudioCodec { public: /** * \brief constructor. * \param Fs Sampling frequency. * \param Addr I2C device address. value range is from 0 to 127 * \details * initialize the internal variables. */ BaseAudioCodec( Fs_Type Fs ); /** * \brief Actual initializer. * \details * Initialize the codec itself and start the conversion process. * and configure for given parameter. * * Finally, set the input gain to 0dB. */ virtual void start(void)=0; /** * \brief Set the line input gain and enable the relevant mixer. * \param left_gain Gain by dB. The gain value outside of the acceptable range will be saturated. * \param right_gain Gain by dB. The gain value outside of the acceptable range will be saturated. * \param mute set true to mute */ virtual void set_line_input_gain(float left_gain, float right_gain, bool mute=false); /** * \brief Set the aux input gain and enable the relevant mixer. * \param left_gain Gain by dB. The gain value outside of the acceptable range will be saturated. * \param right_gain Gain by dB. The gain value outside of the acceptable range will be saturated. * \param mute set true to mute */ virtual void set_aux_input_gain(float left_gain, float right_gain, bool mute=false); /** * \brief Set the mic input gain and enable the relevant mixer. * \param left_gain Gain by dB. The gain value outside of the acceptable range will be saturated. * \param right_gain Gain by dB. The gain value outside of the acceptable range will be saturated. * \param mute set true to mute */ virtual void set_mic_input_gain(float left_gain, float right_gain, bool mute=false); /** * \brief Set the line output gain and enable the relevant mixer. * \param left_gain Gain by dB. The gain value outside of the acceptable range will be saturated. * \param right_gain Gain by dB. The gain value outside of the acceptable range will be saturated. * \param mute set true to mute */ virtual void set_line_output_gain(float left_gain, float right_gain, bool mute=false); /** * \brief Set the headphone output gain and enable the relevant mixer. * \param left_gain Gain by dB. The gain value outside of the acceptable range will be saturated. * \param right_gain Gain by dB. The gain value outside of the acceptable range will be saturated. * \param mute set true to mute */ virtual void set_hp_output_gain(float left_gain, float right_gain, bool mute=false); protected: unsigned int addr; Fs_Type fs; }; } #endif