1060 views|1 replies

108

Posts

8

Resources
The OP
 

[Automatic clock-in and walking timing system based on face recognition] Maixbit/MaixPy pitfall! The audio playback function blocks the call [Copy link]

 

Problem: The audio file is blocked from playing in a loop, and the screen cannot refresh the image captured by the camera in real time (there is a "stuck picture"). Try to use the state machine to play and refresh the LCD at the same time, but the played voice is incomplete (the time of acquisition + LCD is greater than the minimum period of 44.1K playback call).

Slots : 400MHz CPU, 400MHz KPU~~~Such an effect is indeed a bit "unexpected"~~~The reason is that Sipeed/MaixPy~should not use DMA or consider multi-threaded operation when implementing the bottom layer of micropython~~~,

Platform: Maixbit/MaixPy

Task: Camera acquisition + LCD screen refresh + audio playback

Description: Official Documentation: Usage of audio - Sipeed Wiki The play() function must be called in a while(1) Loop

# loop to play audio
while True:
    ret = player.play()
    if ret == None:
        print("format error")
        break
    elif ret==0:
        print("end")
        break

~~I once hoped to use a state machine~~to alleviate the problem by refreshing the LCD while playing~~~~The next step is to try to reduce the samplerate of the WAV file to 8K~~~and see the effect~~~~

#播放状态机
    if (_thread_state == 0):
        music_player = auido_thread_pre(dev, "/sd/4.wav", 50)
        _thread_state = 1
    elif (_thread_state == 1):
        while(True):
            if(True == audio_thread_loop(music_player)):
                _thread_state = 2
                break
            img = sensor.snapshot()
            lcd.display(img)
    elif (_thread_state == 2):
        audio_thread_exit(music_player)
        _thread_state = 3

~~ I don't have time to go deep into the bottom layer of K210~~~~ After the Digi-Jet competition, I will try to compile the firmware myself and try again~~~ Or call the bottom layer C method to customize the bottom layer again~~~

This post is from DigiKey Technology Zone
 
 

108

Posts

8

Resources
2
 
"Found a solution ~ Good news ~": By resampling ~~ and reducing the audio file to 8K sampling rate, it is possible to capture and refresh the LCD image while playing the audio, and the sound is acceptable ~~
This post is from DigiKey Technology Zone
 
 
 

Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list