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モードでの動作が始まります。

参考リンク

Committer:
shorie
Date:
Sat May 14 21:37:32 2016 +0000
Revision:
3:c0f834049ee2
Parent:
2:fba0b8afebf0
Child:
5:bbbf6cd235d4
First Publishment

Who changed what in which revision?

UserRevisionLine numberNew contents of line
shorie 3:c0f834049ee2 1 /*
shorie 1:ea6d442bd68a 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 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 Fs Sampling frequency.
shorie 1:ea6d442bd68a 37 * \param Addr I2C device address. value range is from 0 to 127
shorie 1:ea6d442bd68a 38 * \details
shorie 1:ea6d442bd68a 39 * initialize the internal variables.
shorie 1:ea6d442bd68a 40 */
shorie 2:fba0b8afebf0 41 BaseAudioCodec( Fs_Type Fs );
shorie 1:ea6d442bd68a 42
shorie 1:ea6d442bd68a 43 /**
shorie 1:ea6d442bd68a 44 * \brief Actual initializer.
shorie 1:ea6d442bd68a 45 * \details
shorie 1:ea6d442bd68a 46 * Initialize the codec itself and start the conversion process.
shorie 1:ea6d442bd68a 47 * and configure for given parameter.
shorie 1:ea6d442bd68a 48 *
shorie 1:ea6d442bd68a 49 * Finally, set the input gain to 0dB.
shorie 1:ea6d442bd68a 50 */
shorie 1:ea6d442bd68a 51 virtual void start(void)=0;
shorie 1:ea6d442bd68a 52
shorie 1:ea6d442bd68a 53 /**
shorie 1:ea6d442bd68a 54 * \brief Set the line input gain and enable the relevant mixer.
shorie 1:ea6d442bd68a 55 * \param left_gain Gain by dB. The gain value outside of the acceptable range will be saturated.
shorie 1:ea6d442bd68a 56 * \param right_gain Gain by dB. The gain value outside of the acceptable range will be saturated.
shorie 1:ea6d442bd68a 57 * \param mute set true to mute
shorie 1:ea6d442bd68a 58 */
shorie 1:ea6d442bd68a 59 virtual void set_line_input_gain(float left_gain, float right_gain, bool mute=false);
shorie 1:ea6d442bd68a 60 /**
shorie 1:ea6d442bd68a 61 * \brief Set the aux input gain and enable the relevant mixer.
shorie 1:ea6d442bd68a 62 * \param left_gain Gain by dB. The gain value outside of the acceptable range will be saturated.
shorie 1:ea6d442bd68a 63 * \param right_gain Gain by dB. The gain value outside of the acceptable range will be saturated.
shorie 1:ea6d442bd68a 64 * \param mute set true to mute
shorie 1:ea6d442bd68a 65 */
shorie 1:ea6d442bd68a 66 virtual void set_aux_input_gain(float left_gain, float right_gain, bool mute=false);
shorie 1:ea6d442bd68a 67 /**
shorie 1:ea6d442bd68a 68 * \brief Set the mic input gain and enable the relevant mixer.
shorie 1:ea6d442bd68a 69 * \param left_gain Gain by dB. The gain value outside of the acceptable range will be saturated.
shorie 1:ea6d442bd68a 70 * \param right_gain Gain by dB. The gain value outside of the acceptable range will be saturated.
shorie 1:ea6d442bd68a 71 * \param mute set true to mute
shorie 1:ea6d442bd68a 72 */
shorie 1:ea6d442bd68a 73 virtual void set_mic_input_gain(float left_gain, float right_gain, bool mute=false);
shorie 1:ea6d442bd68a 74 /**
shorie 1:ea6d442bd68a 75 * \brief Set the line output gain and enable the relevant mixer.
shorie 1:ea6d442bd68a 76 * \param left_gain Gain by dB. The gain value outside of the acceptable range will be saturated.
shorie 1:ea6d442bd68a 77 * \param right_gain Gain by dB. The gain value outside of the acceptable range will be saturated.
shorie 1:ea6d442bd68a 78 * \param mute set true to mute
shorie 1:ea6d442bd68a 79 */
shorie 1:ea6d442bd68a 80 virtual void set_line_output_gain(float left_gain, float right_gain, bool mute=false);
shorie 1:ea6d442bd68a 81 /**
shorie 1:ea6d442bd68a 82 * \brief Set the headphone output gain and enable the relevant mixer.
shorie 1:ea6d442bd68a 83 * \param left_gain Gain by dB. The gain value outside of the acceptable range will be saturated.
shorie 1:ea6d442bd68a 84 * \param right_gain Gain by dB. The gain value outside of the acceptable range will be saturated.
shorie 1:ea6d442bd68a 85 * \param mute set true to mute
shorie 1:ea6d442bd68a 86 */
shorie 1:ea6d442bd68a 87 virtual void set_hp_output_gain(float left_gain, float right_gain, bool mute=false);
shorie 1:ea6d442bd68a 88 protected:
shorie 1:ea6d442bd68a 89 unsigned int addr;
shorie 1:ea6d442bd68a 90 Fs_Type fs;
shorie 1:ea6d442bd68a 91 };
shorie 1:ea6d442bd68a 92
shorie 1:ea6d442bd68a 93
shorie 1:ea6d442bd68a 94 }
shorie 1:ea6d442bd68a 95
shorie 1:ea6d442bd68a 96 #endif