{"id":2012,"date":"2025-01-04T23:27:00","date_gmt":"2025-01-04T14:27:00","guid":{"rendered":"https:\/\/ss1.xrea.com\/ike.s206.xrea.com\/wordpress\/?p=2012"},"modified":"2025-01-05T09:21:27","modified_gmt":"2025-01-05T00:21:27","slug":"raspberry-pi-pico-w-%e3%81%a7-bluetooth-audio-receiver-2-2","status":"publish","type":"post","link":"https:\/\/ss1.xrea.com\/ike.s206.xrea.com\/wordpress\/?p=2012","title":{"rendered":"Raspberry Pi Pico W \u3067 Bluetooth Audio Receiver (2\/2)"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/ss1.xrea.com\/ike.s206.xrea.com\/wordpress\/?p=2008\">\u524d\u56de<\/a>\u306fSample Source\u3092\u30d3\u30eb\u30c9\u3057\u305f\u3060\u3051\u3067\u3042\u3063\u3055\u308a\u97f3\u304c\u51fa\u305f\u306e\u3067\u3059\u304c\u3001PWM\u3067\u306e\u97f3\u306a\u306e\u3067\u3082\u3046\u5c11\u3057DAC\u306b\u304a\u91d1\u3092\u304b\u3051\u3088\u3046\u3068\u3001I2S\u30d5\u30a9\u30fc\u30de\u30c3\u30c8\u3092\u51fa\u529b\u3057\u3066\u3001DAC\u306b\u6e21\u3059\u3088\u3046\u306b\u30bd\u30d5\u30c8\u30a6\u30a7\u30a2\u3092\u66f8\u304d\u63db\u3048\u307e\u3057\u305f<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u53c2\u8003\u306b\u3059\u308b\u306e\u306fArudino-IDE\u3068\u3044\u3046\u958b\u767a\u74b0\u5883\u306e Arduino-Pico \u3068\u3044\u3046\u3082\u306e\u3067Sample Source(\u30b9\u30b1\u30c3\u30c1)\u306e<br>\u30b9\u30b1\u30c3\u30c1 \u3068\u306f\u3001Arduino(\u30a2\u30eb\u30c7\u30e5\u30a4\u30fc\u30ce) \u306e<a href=\"https:\/\/www.denshi.club\/make\/arduinoorg\/arduino-ref01b.html\">\u4ed5\u7d44\u307f\u306e\u7528\u8a9e<\/a>\u3067\u3059\u3002\u5c0f\u5b66\u751f\u306e\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u306a\u3069\u3067\u3082\u4f7f\u308f\u308c\u3066\u3044\u3066\u3001\u4ed5\u7d44\u307f\u3092\u7406\u89e3\u3059\u308b\u3068\u3001\u6bd4\u8f03\u7684\u7c21\u5358\u306b\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u3067\u304d\u307e\u3059<br>\u524d\u56de\u306e BluetoothAudio > A2DPSink \u3068\u3044\u3046\u30bd\u30fc\u30b9\u306b\u3001I2S > SimpleTone \u306e\u51e6\u7406\u3092\u8ffd\u52a0\/\u7de8\u96c6\u3057\u3066 PWM \u306b\u51fa\u529b\u3057\u3066\u3044\u305f\u3082\u306e\u3092I2S\u30e2\u30b8\u30e5\u30fc\u30eb\u306b\u51fa\u529b\u3059\u308b\u3088\u3046\u306b\u5909\u66f4\u3057\u307e\u3059<br><br>DAC\u306fGY-PCM5201\u3068\u3044\u3046DAC\u57fa\u677f\u3067\u3001\u4e2d\u83ef\u88fd\u3067\u5b89\u3044\u306e\u3092\u8cb7\u3063\u305f\u3089\u3069\u3046\u3082\u6a21\u5023\u54c1\u3089\u3057\u304f\u3066\u57fa\u677f\u306e\u88cf\u306e\u30b7\u30eb\u30af\u3067 LRCK \u306e\u306f\u305a\u306e\u3068\u3053\u308d\u304c RCK \u306b\u306a\u3063\u3066\u3044\u307e\u3057\u305f (\u6c57)<br>IC\u306e\u30b7\u30eb\u30af\u306f\u6b63\u3057\u3044\u305d\u3046\u3067\u3059\u304c\u30ce\u30a4\u30ba\u304c\u591a\u3044\u3067\u3059<br>Appendix<br>1. \u56de\u8def\u56f3<br>2. \u5199\u771f (\u30df\u30cb\u30b9\u30c6\u30ec\u30aa\u3067\u30d8\u30c3\u30c9\u30db\u30f3\u3067\u805e\u3051\u308b)<br>3. \u30b9\u30de\u30db\u3067 Bluetooth Audio \u306e\u63a5\u7d9a \u540d\u524d\u3092 PicoW Rx \u306b\u3057\u3066\u307f\u307e\u3057\u305f<br>4. \u5909\u66f4\u3057\u305f\u5dee\u5206<br><\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"724\" src=\"https:\/\/ss1.xrea.com\/ike.s206.xrea.com\/wordpress\/wp-content\/uploads\/2025\/01\/Pico_pcm5102a_\u56de\u8def\u56f3-1024x724.png\" alt=\"\u56de\u8def\u56f3\" class=\"wp-image-2027\" style=\"width:548px;height:auto\" srcset=\"https:\/\/ss1.xrea.com\/ike.s206.xrea.com\/wordpress\/wp-content\/uploads\/2025\/01\/Pico_pcm5102a_\u56de\u8def\u56f3-1024x724.png 1024w, https:\/\/ss1.xrea.com\/ike.s206.xrea.com\/wordpress\/wp-content\/uploads\/2025\/01\/Pico_pcm5102a_\u56de\u8def\u56f3-300x212.png 300w, https:\/\/ss1.xrea.com\/ike.s206.xrea.com\/wordpress\/wp-content\/uploads\/2025\/01\/Pico_pcm5102a_\u56de\u8def\u56f3-768x543.png 768w, https:\/\/ss1.xrea.com\/ike.s206.xrea.com\/wordpress\/wp-content\/uploads\/2025\/01\/Pico_pcm5102a_\u56de\u8def\u56f3.png 1123w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"768\" src=\"https:\/\/ss1.xrea.com\/ike.s206.xrea.com\/wordpress\/wp-content\/uploads\/2025\/01\/IMG_20250104_150053-1024x768.jpg\" alt=\"\" class=\"wp-image-2025\" style=\"width:477px;height:auto\" srcset=\"https:\/\/ss1.xrea.com\/ike.s206.xrea.com\/wordpress\/wp-content\/uploads\/2025\/01\/IMG_20250104_150053-1024x768.jpg 1024w, https:\/\/ss1.xrea.com\/ike.s206.xrea.com\/wordpress\/wp-content\/uploads\/2025\/01\/IMG_20250104_150053-300x225.jpg 300w, https:\/\/ss1.xrea.com\/ike.s206.xrea.com\/wordpress\/wp-content\/uploads\/2025\/01\/IMG_20250104_150053-768x576.jpg 768w, https:\/\/ss1.xrea.com\/ike.s206.xrea.com\/wordpress\/wp-content\/uploads\/2025\/01\/IMG_20250104_150053-1536x1152.jpg 1536w, https:\/\/ss1.xrea.com\/ike.s206.xrea.com\/wordpress\/wp-content\/uploads\/2025\/01\/IMG_20250104_150053-2048x1536.jpg 2048w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"473\" height=\"1024\" src=\"https:\/\/ss1.xrea.com\/ike.s206.xrea.com\/wordpress\/wp-content\/uploads\/2025\/01\/Screenshot_20250104-150906-473x1024.png\" alt=\"\" class=\"wp-image-2026\" style=\"width:303px;height:auto\" srcset=\"https:\/\/ss1.xrea.com\/ike.s206.xrea.com\/wordpress\/wp-content\/uploads\/2025\/01\/Screenshot_20250104-150906-473x1024.png 473w, https:\/\/ss1.xrea.com\/ike.s206.xrea.com\/wordpress\/wp-content\/uploads\/2025\/01\/Screenshot_20250104-150906-138x300.png 138w, https:\/\/ss1.xrea.com\/ike.s206.xrea.com\/wordpress\/wp-content\/uploads\/2025\/01\/Screenshot_20250104-150906-768x1664.png 768w, https:\/\/ss1.xrea.com\/ike.s206.xrea.com\/wordpress\/wp-content\/uploads\/2025\/01\/Screenshot_20250104-150906-709x1536.png 709w, https:\/\/ss1.xrea.com\/ike.s206.xrea.com\/wordpress\/wp-content\/uploads\/2025\/01\/Screenshot_20250104-150906-945x2048.png 945w, https:\/\/ss1.xrea.com\/ike.s206.xrea.com\/wordpress\/wp-content\/uploads\/2025\/01\/Screenshot_20250104-150906-1024x2219.png 1024w, https:\/\/ss1.xrea.com\/ike.s206.xrea.com\/wordpress\/wp-content\/uploads\/2025\/01\/Screenshot_20250104-150906.png 1080w\" sizes=\"auto, (max-width: 473px) 100vw, 473px\" \/><\/figure>\n\n\n\n<pre class=\"wp-block-code\"><code>diff --git a\/A2DPSink.ino b\/A2DPSink_00a.ino\nindex 32dc30f..3ab3582 100755\n--- a\/A2DPSink.ino\n+++ b\/A2DPSink_00a.ino\n@@ -3,10 +3,22 @@\n \/\/ Hook up a phono plug to GP0 and GP1 (and GND of course...the 1st 3 pins on the PCB)\n \/\/ Connect wired earbuds up and connect over BT from your phone and play some music.\n \n+\n #include &lt;BluetoothAudio.h&gt;\n-#include &lt;PWMAudio.h&gt;\n+#include &lt;I2S.h&gt;\n+#include &lt;Time.h&gt;\n+\n+I2S i2s(OUTPUT); \/\/ audio Consumer\n+\/\/ GPIO pin numbers 26-28 (31,32,34pin)\n+#define pBCLK 26\n+#define pWS (pBCLK+1)\n+#define pDOUT 28\n+#define pMCLK 19  \/\/ optional MCLK pin\n+const int sampleRate = 48000; \/\/ minimum for UDA1334A\n+\n+#define MCLK_MUL  256     \/\/ depends on audio hardware. Suits common hardware.\n+#define PIN_XSMT (16)\n \n-PWMAudio pwm;\n A2DPSink a2dp;\n \n volatile A2DPSink::PlaybackStatus status = A2DPSink::STOPPED;\n@@ -31,13 +43,26 @@ void playbackCB(void *param, A2DPSink::PlaybackStatus state) {\n }\n \n void setup() {\n+  pinMode(LED_BUILTIN, OUTPUT);\n+  digitalWrite(LED_BUILTIN, 1);\n+  pinMode(PIN_XSMT, OUTPUT);\n+\/\/  digitalWrite(PIN_XSMT, HIGH); \n+\n   Serial.begin(115200);\n   delay(3000);\n   Serial.printf(\"Starting, connect to the PicoW and start playing music\\n\");\n   Serial.printf(\"Use BOOTSEL to pause\/resume playback\\n\");\n-  a2dp.setName(\"PicoW Boom 00:00:00:00:00:00\");\n-  a2dp.setConsumer(new BluetoothAudioConsumerPWM(pwm));\n-  a2dp.onVolume(volumeCB);\n+  a2dp.setName(\"PicoW RX 00:00:00:00:00:00\");\n+  a2dp.setConsumer(new BluetoothAudioConsumerI2S(i2s));\n+  i2s.setBCLK(pBCLK);\n+  i2s.setDATA(pDOUT);\n+  i2s.setBitsPerSample(16); \/\/ 8,16,24,32\n+\n+  if (!i2s.begin(sampleRate)) {\n+    Serial.println(\"Failed to initialize I2S!\");\n+    while (1); \/\/ do nothing\n+  }\n+\n   a2dp.onConnect(connectCB);\n   a2dp.onPlaybackStatus(playbackCB);\n   a2dp.begin();\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u524d\u56de\u306fSample Source\u3092\u30d3\u30eb\u30c9\u3057\u305f\u3060\u3051\u3067\u3042\u3063\u3055\u308a\u97f3\u304c\u51fa\u305f\u306e\u3067\u3059\u304c\u3001PWM\u3067\u306e\u97f3\u306a\u306e\u3067\u3082\u3046\u5c11\u3057DAC\u306b\u304a\u91d1\u3092\u304b\u3051\u3088\u3046\u3068\u3001I2S\u30d5\u30a9\u30fc\u30de\u30c3\u30c8\u3092\u51fa\u529b\u3057\u3066\u3001DAC\u306b\u6e21\u3059\u3088\u3046\u306b\u30bd\u30d5\u30c8\u30a6\u30a7\u30a2\u3092\u66f8\u304d\u63db\u3048\u307e\u3057\u305f \u53c2\u8003\u306b\u3059\u308b\u306e\u306f [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"class_list":["post-2012","post","type-post","status-publish","format-standard","hentry","category-4"],"_links":{"self":[{"href":"https:\/\/ss1.xrea.com\/ike.s206.xrea.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/2012","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ss1.xrea.com\/ike.s206.xrea.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ss1.xrea.com\/ike.s206.xrea.com\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ss1.xrea.com\/ike.s206.xrea.com\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ss1.xrea.com\/ike.s206.xrea.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2012"}],"version-history":[{"count":0,"href":"https:\/\/ss1.xrea.com\/ike.s206.xrea.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/2012\/revisions"}],"wp:attachment":[{"href":"https:\/\/ss1.xrea.com\/ike.s206.xrea.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2012"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ss1.xrea.com\/ike.s206.xrea.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2012"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ss1.xrea.com\/ike.s206.xrea.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2012"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}