Skip to content

Commit a00cddb

Browse files
committed
lib/unit: Fix PDM Unit example recording sound irregularity.
Signed-off-by: tinyu <tinyu@m5stack.com>
1 parent fbf7c1e commit a00cddb

File tree

2 files changed

+22
-18
lines changed

2 files changed

+22
-18
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"version":"V2.0","versionNumber":"V2.2.3","type":"cores3","components":[{"name":"screen","type":"screen","layer":0,"screenId":"builtin","screenName":"","id":"__cores3_screen","createTime":1717660236218,"x":0,"y":0,"width":320,"height":240,"backgroundColor":"#222222","size":0,"isSelected":true},{"name":"label0","type":"label","layer":1,"screenId":"builtin","screenName":"","id":"rW^fX1*1vprMa8z@","createTime":1717660555376,"x":128,"y":114,"color":"#ffffff","backgroundColor":"#222222","text":"label0","engine":"gfx","font":"Widgets.FONTS.DejaVu18","rotation":0,"isSelected":false,"width":58,"height":21},{"name":"title0","type":"title","layer":1,"screenId":"builtin","screenName":"","id":"fUyX^usfI`lUa7#%","createTime":1742349913202,"x":0,"y":0,"color":"#ffffff","backgroundColor":"#0000FF","text":"PDMUnit CoreS3 Example","textOffset":3,"font":"Widgets.FONTS.DejaVu18","isSelected":false}],"resources":[{"hardware":["hardware_button","hardware_pin_button","imu","speaker","touch","als","mic"]},{"unit":["unit_pdm"]}],"units":[{"type":"unit_pdm","name":"pdm_0","portList":["A","B","C","Custom"],"portType":"A","userPort":[22,21],"id":"gss%Q0aN!0e$&#RW","createTime":1742349854435,"initBlockId":"bMOGU7vj4{9Vi2SNi)9z"}],"hats":[],"bases":[],"i2cs":[],"blockly":"<variables><variable id=\"4%}H+^k{-@CNg:6Dz.Ui\">rec_data</variable></variables><block type=\"basic_on_setup\" id=\"setup_block\" deletable=\"false\" x=\"50\" y=\"57\"><mutation isBegin=\"true\"></mutation><field name=\"UPDATEOP\">true</field><statement name=\"FUNC\"><block type=\"system_m5_begin\" id=\"system_m5_begin\"><next><block type=\"unit_pdm_init\" id=\"bMOGU7vj4{9Vi2SNi)9z\"><field name=\"NAME\">pdm_0</field><value name=\"I2S\"><shadow type=\"math_number\" id=\"6lcYQ0[F#0K|S3-S[p*F\"><mutation max=\"Infinity\" min=\"-Infinity\" precision=\"0\"></mutation><field name=\"NUM\">2</field></shadow></value><value name=\"RATE\"><shadow type=\"math_number\" id=\"e`zmME=PmGvemqJgG2P`\"><mutation max=\"Infinity\" min=\"-Infinity\" precision=\"0\"></mutation><field name=\"NUM\">44100</field></shadow></value><next><block type=\"speaker_begin\" id=\"Waedt`B3E@ls7++kt#,L\"><next><block type=\"speaker_set_volume_percentage\" id=\"H(U;JLe0A~UN+Am9:_0^\"><value name=\"VOLUME\"><shadow type=\"math_slider\" id=\"-x5E)kll7X#lIX$|mICL\"><mutation max=\"100\" min=\"0\" step=\"1\" precision=\"1\"></mutation><field name=\"NUM\">100</field></shadow></value><next><block type=\"speaker_end\" id=\"8,p^~P@$J6pXx;E0[vxm\"><next><block type=\"unit_pdm_begin\" id=\"DijgqR{~/#LI`v]j-nt0\"><field name=\"NAME\">pdm_0</field><next><block type=\"variables_set\" id=\"Dfb4/ef-=g7po+-E%=]v\"><field name=\"VAR\" id=\"4%}H+^k{-@CNg:6Dz.Ui\">rec_data</field><value name=\"VALUE\"><block type=\"bytearray_create_empty\" id=\"RIbSwGc.-w1{2-1c(gnn\"><value name=\"LENGTH\"><shadow type=\"math_number\" id=\")qz,{I@,p++%jT}K[Dez\"><mutation max=\"Infinity\" min=\"-Infinity\" precision=\"0\"></mutation><field name=\"NUM\">1</field></shadow><block type=\"math_arithmetic\" id=\"Zi(p2z0i/7zzn^Sy#S.5\"><field name=\"OP\">MULTIPLY</field><value name=\"A\"><shadow type=\"math_number\" id=\"`}2xrZX5Z9okcHQUJ_UY\"><mutation max=\"Infinity\" min=\"-Infinity\" precision=\"0\"></mutation><field name=\"NUM\">44100</field></shadow></value><value name=\"B\"><shadow type=\"math_number\" id=\"J@?:c:3xYV#?wM(2NaTX\"><mutation max=\"Infinity\" min=\"-Infinity\" precision=\"0\"></mutation><field name=\"NUM\">10</field></shadow></value></block></value></block></value><next><block type=\"label_set_text\" id=\"1!|VrVohPRdBTiGM4xnR\"><field name=\"NAME\">label0</field><value name=\"TEXT\"><shadow type=\"text\" id=\"fMiAtuU8wt%A@;:Pp74i\"><field name=\"TEXT\">rec...</field></shadow></value><next><block type=\"unit_pdm_set_record\" id=\"xnv;XY4zJ8Iji`tc/4z7\"><field name=\"NAME\">pdm_0</field><field name=\"VALUE\">False</field><value name=\"BUF\"><block type=\"variables_get\" id=\"Kh?(TGtENeRV`chn$2!n\"><field name=\"VAR\" id=\"4%}H+^k{-@CNg:6Dz.Ui\">rec_data</field></block></value><next><block type=\"time_sleep_millisecond\" id=\"Dd$p+B;ai{^Rs9+Tit.Y\"><value name=\"MS\"><shadow type=\"math_number\" id=\"NAZnn9`^nPfw[|KDhl@w\"><mutation max=\"Infinity\" min=\"0\" precision=\"0\"></mutation><field name=\"NUM\">100</field></shadow></value><next><block type=\"controls_whileUntil\" id=\"5#EdTdqgh[.R8QN(1Q^E\"><field name=\"MODE\">WHILE</field><value name=\"BOOL\"><block type=\"unit_pdm_is_recording\" id=\"#UnKjcL74=Gi./``lK,k\"><field name=\"NAME\">pdm_0</field></block></value><statement name=\"DO\"><block type=\"label_set_text\" id=\"W(vFM,06(BO5BYmz{T!0\"><field name=\"NAME\">label0</field><value name=\"TEXT\"><shadow type=\"text\" id=\"r_JW7Fd)8U~C=Df!BFO_\"><field name=\"TEXT\">rec...</field></shadow></value><next><block type=\"time_sleep_millisecond\" id=\"Evz=xNbekls,uj55@t*J\"><value name=\"MS\"><shadow type=\"math_number\" id=\"C.r)0RA-f0DkJcPJe7R]\"><mutation max=\"Infinity\" min=\"0\" precision=\"0\"></mutation><field name=\"NUM\">100</field></shadow></value></block></next></block></statement><next><block type=\"unit_pdm_end\" id=\"_tE35.gHe~@ZR{jFqtU}\"><field name=\"NAME\">pdm_0</field><next><block type=\"speaker_begin\" id=\"I0KfhG_#VzZn=ka6U^on\"><next><block type=\"label_set_text\" id=\"%v:4_qt8l/26esZwd+te\"><field name=\"NAME\">label0</field><value name=\"TEXT\"><shadow type=\"text\" id=\"28la7H$~[lsl?)1K[E}V\"><field name=\"TEXT\">play...</field></shadow></value><next><block type=\"speaker_play_raw\" id=\"ZN}Yi^=v?O59a?|b]xmU\"><value name=\"BUFFER\"><block type=\"variables_get\" id=\"9|,cgB]#.mY?D*@cxfAj\"><field name=\"VAR\" id=\"4%}H+^k{-@CNg:6Dz.Ui\">rec_data</field></block></value><value name=\"RATE\"><shadow type=\"math_number\" id=\"tdd7r$by/ntCVz+JtrgF\"><mutation max=\"Infinity\" min=\"-Infinity\" precision=\"0\"></mutation><field name=\"NUM\">16000</field></shadow><block type=\"math_arithmetic\" id=\"3b1WFY;zC!B~wBOc5_bj\"><field name=\"OP\">MULTIPLY</field><value name=\"A\"><shadow type=\"math_number\" id=\"5ydQsY_XC*NJ~apNUUco\"><mutation max=\"Infinity\" min=\"-Infinity\" precision=\"0\"></mutation><field name=\"NUM\">44100</field></shadow></value><value name=\"B\"><shadow type=\"math_number\" id=\"_fBo:%tjJk_xrk7O1uf@\"><mutation max=\"Infinity\" min=\"-Infinity\" precision=\"0\"></mutation><field name=\"NUM\">2</field></shadow></value></block></value><next><block type=\"controls_whileUntil\" id=\"7pCOInt:fNv|(~k=]Mrv\"><field name=\"MODE\">WHILE</field><value name=\"BOOL\"><block type=\"speaker_is_playing\" id=\".57pFwd(Kqk)2aI|D|?m\"></block></value><statement name=\"DO\"><block type=\"time_sleep_millisecond\" id=\"O^g?~{NU/?!_]7|A}$t1\"><value name=\"MS\"><shadow type=\"math_number\" id=\"n6#4Co0+jTuR@]X_RImy\"><mutation max=\"Infinity\" min=\"0\" precision=\"0\"></mutation><field name=\"NUM\">100</field></shadow></value></block></statement><next><block type=\"label_set_text\" id=\"+VQdzgVla`u:A$O@(+MU\"><field name=\"NAME\">label0</field><value name=\"TEXT\"><shadow type=\"text\" id=\"VQy!oI=8Vx4ShK:UEqfb\"><field name=\"TEXT\">done</field></shadow></value></block></next></block></next></block></next></block></next></block></next></block></next></block></next></block></next></block></next></block></next></block></next></block></next></block></next></block></next></block></next></block></next></block></statement></block><block type=\"basic_on_loop\" id=\"loop_block\" deletable=\"false\" x=\"50\" y=\"890\"><mutation isUpdate=\"true\"></mutation><field name=\"UPDATEOP\">true</field><statement name=\"FUNC\"><block type=\"system_m5_update\" id=\"system_m5_update\"></block></statement></block>","screen":[{"simulationName":"Built-in","type":"builtin","width":320,"height":240,"scale":0.78,"screenName":"","blockId":"","screenColorType":0,"id":"builtin","createTime":1717660236214}],"logicWhenNum":0,"customList":[]}
1+
{"version":"V2.0","versionNumber":"V2.2.6","type":"cores3","components":[{"name":"screen","type":"screen","layer":0,"screenId":"builtin","screenName":"","id":"__cores3_screen","createTime":1745542990818,"x":0,"y":0,"width":320,"height":240,"backgroundColor":"#222222","size":0,"isSelected":true},{"name":"title0","type":"title","layer":1,"screenId":"builtin","screenName":"","id":"pmFdx@hpgkF&dZ*Y","createTime":1745546428599,"x":0,"y":0,"color":"#ffffff","backgroundColor":"#0000FF","text":"PDMUnit CoreS3 Example","textOffset":3,"font":"Widgets.FONTS.DejaVu18","isSelected":false},{"name":"label0","type":"label","layer":2,"screenId":"builtin","screenName":"","id":"z3xtO^jX5L6NiSap","createTime":1745546458604,"x":20,"y":54,"color":"#ffffff","backgroundColor":"#222222","text":"Is Start:","engine":"gfx","font":"Widgets.FONTS.DejaVu18","rotation":0,"isSelected":false},{"name":"label1","type":"label","layer":3,"screenId":"builtin","screenName":"","id":"j02KcYbv!cFfZ%6d","createTime":1745546460950,"x":20,"y":119,"color":"#ffffff","backgroundColor":"#222222","text":"Is Done:","engine":"gfx","font":"Widgets.FONTS.DejaVu18","rotation":0,"isSelected":false},{"name":"label2","type":"label","layer":4,"screenId":"builtin","screenName":"","id":"nQ`mk`kRGg^_91OA","createTime":1745546464517,"x":131,"y":52,"color":"#ffffff","backgroundColor":"#222222","text":"label2","engine":"gfx","font":"Widgets.FONTS.DejaVu18","rotation":0,"isSelected":false},{"name":"label3","type":"label","layer":5,"screenId":"builtin","screenName":"","id":"bo3#slwDGB+sP4qV","createTime":1745546466269,"x":133,"y":121,"color":"#ffffff","backgroundColor":"#222222","text":"label3","engine":"gfx","font":"Widgets.FONTS.DejaVu18","rotation":0,"isSelected":false}],"resources":[{"hardware":["hardware_button","hardware_pin_button","imu","speaker","touch","als","mic"]},{"unit":["unit_pdm"]}],"units":[{"type":"unit_pdm","name":"pdm_0","portList":["A","B","C","Custom"],"portType":"A","userPort":[22,21],"id":"m%fNJStfZIUEVGNo","createTime":1745921027358,"initBlockId":"u-t5ezs22vVmOt;I(m?("}],"hats":[],"bases":[],"i2cs":[],"blockly":"<variables><variable id=\"prQMZK*cbV@(z;cE!!4:\">rec_data</variable></variables><block type=\"basic_on_setup\" id=\"setup_block\" deletable=\"false\" x=\"50\" y=\"50\"><mutation isBegin=\"true\"></mutation><field name=\"UPDATEOP\">true</field><statement name=\"FUNC\"><block type=\"system_m5_begin\" id=\"system_m5_begin\"><next><block type=\"unit_pdm_init\" id=\"u-t5ezs22vVmOt;I(m?(\"><field name=\"NAME\">pdm_0</field><value name=\"I2S\"><shadow type=\"math_number\" id=\"jJ^wO,j_d)P70+T{(+n:\"><mutation max=\"Infinity\" min=\"-Infinity\" precision=\"0\"></mutation><field name=\"NUM\">2</field></shadow></value><value name=\"RATE\"><shadow type=\"unit_pdm_rate_option\" id=\"9K4tU,EMDk]#q4ESsKd-\"><field name=\"VALUE\">44100</field></shadow></value><next><block type=\"speaker_begin\" id=\"oPKrLT!XLjIGEwz==3+{\"><next><block type=\"speaker_set_volume_percentage\" id=\")$)d$lU[M_CIZ/@-9Tm,\"><value name=\"VOLUME\"><shadow type=\"math_slider\" id=\"5W:]t,KHJ]TJQ:QM.kFY\"><mutation max=\"100\" min=\"0\" step=\"1\" precision=\"1\"></mutation><field name=\"NUM\">100</field></shadow></value><next><block type=\"speaker_end\" id=\"(DTF^]isY5.pgn)}/([`\"><next><block type=\"unit_pdm_begin\" id=\"z?RavMc^xs2yfX3*OgbT\"><field name=\"NAME\">pdm_0</field><next><block type=\"label_set_text\" id=\";aK5+|;vSJjw+@*P;8_c\"><field name=\"NAME\">label2</field><value name=\"TEXT\"><shadow type=\"text\" id=\"Id)5S0i0[,sHRiupFEM{\"><field name=\"TEXT\">waiting...</field></shadow></value><next><block type=\"time_sleep_second\" id=\"1:tyO)!qS.k^S|8olP^B\"><value name=\"SECOND\"><shadow type=\"math_number\" id=\"xp+/0Tp4e`iuXu[semKP\"><mutation max=\"Infinity\" min=\"0\" precision=\"0\"></mutation><field name=\"NUM\">2</field></shadow></value><next><block type=\"variables_set\" id=\"0zJ{l}~Mo{|l6)8V+t.D\"><field name=\"VAR\" id=\"prQMZK*cbV@(z;cE!!4:\">rec_data</field><value name=\"VALUE\"><block type=\"bytearray_create_empty\" id=\"t!ySkZX}mOuDny5Um4Rb\"><value name=\"LENGTH\"><shadow type=\"math_number\" id=\";OB(KA@3;5[u)rNA.z_{\"><mutation max=\"Infinity\" min=\"-Infinity\" precision=\"0\"></mutation><field name=\"NUM\">1</field></shadow><block type=\"math_arithmetic\" id=\"[SN}IO#7[wyb481;!**t\"><field name=\"OP\">MULTIPLY</field><value name=\"A\"><shadow type=\"math_number\" id=\"Z:}[j[ozcZr^YM:iNc18\"><mutation max=\"Infinity\" min=\"-Infinity\" precision=\"0\"></mutation><field name=\"NUM\">44100</field></shadow></value><value name=\"B\"><shadow type=\"math_number\" id=\"vm:/CNw9.`eRy*Nf:AI_\"><mutation max=\"Infinity\" min=\"-Infinity\" precision=\"0\"></mutation><field name=\"NUM\">15</field></shadow></value></block></value></block></value><next><block type=\"unit_pdm_set_record\" id=\"|_s.=?)7.zw$C.j`pl8I\"><field name=\"NAME\">pdm_0</field><field name=\"VALUE\">False</field><value name=\"BUF\"><block type=\"variables_get\" id=\"H8.a+pQD@VOx,B1P{m|/\"><field name=\"VAR\" id=\"prQMZK*cbV@(z;cE!!4:\">rec_data</field></block></value><value name=\"RATE\"><shadow type=\"unit_pdm_rate_option\" id=\"(wjCdY2y{7nahyz=L1d0\"><field name=\"VALUE\">44100</field></shadow></value><next><block type=\"time_sleep_millisecond\" id=\"GH{OE7@gY6]pl~7~X#oI\"><value name=\"MS\"><shadow type=\"math_number\" id=\"7{zCmR*7.K]r2_Q$rB_o\"><mutation max=\"Infinity\" min=\"0\" precision=\"0\"></mutation><field name=\"NUM\">150</field></shadow></value><next><block type=\"controls_whileUntil\" id=\"KzBFq1jCWz=rv8oZC*pT\"><field name=\"MODE\">WHILE</field><value name=\"BOOL\"><block type=\"unit_pdm_is_recording\" id=\"}%iBZNnqb6}(nP)|5^*]\"><field name=\"NAME\">pdm_0</field></block></value><statement name=\"DO\"><block type=\"label_set_text\" id=\"1tOa/MDzG1Po%93c],lR\"><field name=\"NAME\">label2</field><value name=\"TEXT\"><shadow type=\"text\" id=\"vIuvr(h_NIU}GKq^jnRn\"><field name=\"TEXT\">recording...</field></shadow></value><next><block type=\"time_sleep_millisecond\" id=\"FMW){Wi)4%Rtl,ARvo|?\"><value name=\"MS\"><shadow type=\"math_number\" id=\"GDVmtiH[sF[N3arfVcf2\"><mutation max=\"Infinity\" min=\"0\" precision=\"0\"></mutation><field name=\"NUM\">100</field></shadow></value></block></next></block></statement><next><block type=\"unit_pdm_end\" id=\"U9BFd6FCXrr=k?uo~@ky\"><field name=\"NAME\">pdm_0</field><next><block type=\"label_set_text\" id=\"+)~qy!%g.bIpmbN:)joY\"><field name=\"NAME\">label2</field><value name=\"TEXT\"><shadow type=\"text\" id=\"Hoqxh86Yy~u2oq[$dMSl\"><field name=\"TEXT\">ending...</field></shadow></value><next><block type=\"speaker_begin\" id=\"V7pVk#=/Sg;n!|7AvySA\"><next><block type=\"label_set_text\" id=\"KsI%m{sR{4p-rJ=!4ier\"><field name=\"NAME\">label3</field><value name=\"TEXT\"><shadow type=\"text\" id=\"9M+:3t6Rrvw,Ed]j$Bu2\"><field name=\"TEXT\">playing...</field></shadow></value><next><block type=\"speaker_play_raw\" id=\"b*e[5Hbn1n)t|oex$@9f\"><value name=\"BUFFER\"><block type=\"variables_get\" id=\"9Bwkvr*JkL0!nM@y_^B#\"><field name=\"VAR\" id=\"prQMZK*cbV@(z;cE!!4:\">rec_data</field></block></value><value name=\"RATE\"><shadow type=\"math_number\" id=\"*kI6zC^!E(cVBft.U5?D\"><mutation max=\"Infinity\" min=\"-Infinity\" precision=\"0\"></mutation><field name=\"NUM\">44100</field></shadow></value><next><block type=\"controls_whileUntil\" id=\"5Q(BW.{mI5]i*MvghB/T\"><field name=\"MODE\">WHILE</field><value name=\"BOOL\"><block type=\"speaker_is_playing\" id=\"7Sie-ND+ARI-6nx6+w5,\"></block></value><statement name=\"DO\"><block type=\"time_sleep_millisecond\" id=\"bcMT5:-eG]2vAzKw_@p/\"><value name=\"MS\"><shadow type=\"math_number\" id=\"5`ab==l5~E3XIKxfwR0=\"><mutation max=\"Infinity\" min=\"0\" precision=\"0\"></mutation><field name=\"NUM\">150</field></shadow></value></block></statement><next><block type=\"label_set_text\" id=\"0F~zHryOO$~DnF@1h(Y,\"><field name=\"NAME\">label3</field><value name=\"TEXT\"><shadow type=\"text\" id=\"1|nQ(}atHWHwRU@j67h[\"><field name=\"TEXT\">done</field></shadow></value></block></next></block></next></block></next></block></next></block></next></block></next></block></next></block></next></block></next></block></next></block></next></block></next></block></next></block></next></block></next></block></next></block></next></block></next></block></statement></block><block type=\"basic_on_loop\" id=\"loop_block\" deletable=\"false\" x=\"550\" y=\"50\"><mutation isUpdate=\"true\"></mutation><field name=\"UPDATEOP\">true</field><statement name=\"FUNC\"><block type=\"system_m5_update\" id=\"system_m5_update\"></block></statement></block>","screen":[{"simulationName":"Built-in","type":"builtin","width":320,"height":240,"scale":0.78,"screenName":"","blockId":"","screenColorType":0,"id":"builtin","createTime":1745542990815}],"logicWhenNum":0,"customList":[]}

examples/unit/pdm/pdm_cores3_example.py

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,57 @@
1-
# SPDX-FileCopyrightText: 2024 M5Stack Technology CO LTD
2-
#
3-
# SPDX-License-Identifier: MIT
4-
51
import os, sys, io
62
import M5
73
from M5 import *
84
from unit import PDMUnit
95
import time
106

117

12-
label0 = None
138
title0 = None
9+
label0 = None
10+
label1 = None
11+
label2 = None
12+
label3 = None
1413
pdm_0 = None
1514

1615

1716
rec_data = None
1817

1918

2019
def setup():
21-
global label0, title0, pdm_0, rec_data
20+
global title0, label0, label1, label2, label3, pdm_0, rec_data
2221

2322
M5.begin()
2423
Widgets.fillScreen(0x222222)
25-
label0 = Widgets.Label("label0", 128, 114, 1.0, 0xFFFFFF, 0x222222, Widgets.FONTS.DejaVu18)
2624
title0 = Widgets.Title("PDMUnit CoreS3 Example", 3, 0xFFFFFF, 0x0000FF, Widgets.FONTS.DejaVu18)
25+
label0 = Widgets.Label("Is Start:", 20, 54, 1.0, 0xFFFFFF, 0x222222, Widgets.FONTS.DejaVu18)
26+
label1 = Widgets.Label("Is Done:", 20, 119, 1.0, 0xFFFFFF, 0x222222, Widgets.FONTS.DejaVu18)
27+
label2 = Widgets.Label("label2", 131, 52, 1.0, 0xFFFFFF, 0x222222, Widgets.FONTS.DejaVu18)
28+
label3 = Widgets.Label("label3", 133, 121, 1.0, 0xFFFFFF, 0x222222, Widgets.FONTS.DejaVu18)
2729

2830
pdm_0 = PDMUnit((1, 2), i2s_port=2, sample_rate=44100)
2931
Speaker.begin()
3032
Speaker.setVolumePercentage(1)
3133
Speaker.end()
3234
pdm_0.begin()
33-
rec_data = bytearray(44100 * 10)
34-
label0.setText(str("rec..."))
35-
pdm_0.record(rec_data, _, False)
36-
time.sleep_ms(100)
35+
label2.setText(str("waiting..."))
36+
time.sleep(2)
37+
rec_data = bytearray(44100 * 15)
38+
pdm_0.record(rec_data, 44100, False)
39+
time.sleep_ms(150)
3740
while pdm_0.isRecording():
38-
label0.setText(str("rec..."))
41+
label2.setText(str("recording..."))
3942
time.sleep_ms(100)
4043
pdm_0.end()
44+
label2.setText(str("ending..."))
4145
Speaker.begin()
42-
label0.setText(str("play..."))
43-
Speaker.playRaw(rec_data, 44100 * 2)
46+
label3.setText(str("playing..."))
47+
Speaker.playRaw(rec_data, 44100)
4448
while Speaker.isPlaying():
45-
time.sleep_ms(100)
46-
label0.setText(str("done"))
49+
time.sleep_ms(150)
50+
label3.setText(str("done"))
4751

4852

4953
def loop():
50-
global label0, title0, pdm_0, rec_data
54+
global title0, label0, label1, label2, label3, pdm_0, rec_data
5155
M5.update()
5256

5357

0 commit comments

Comments
 (0)