micropython
micropython copied to clipboard
preliminary audio support
Hello everyone and thank you for the great job done so far! :)
Let’s wait for pulkin
Can you give more details on this? Did you test it? What formats it supports? Where does it output sound? Can you play it as a voice mail?
I test to record in default amr format it's works ok. recording in mp3 halted the board palying amr,mp3 files is ok aac not tested speaker volume is ok but delay about 0.3s to change from last volume value.
there are a bug, when audio.play_start no existed file, you must run audio.play_stop() first
>>> audio.play_start("/t/no_existe_file.amr",15)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: cannot play audio file
>>> audio.play_start("/t/2.amr",15)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: cannot play audio file
>>> audio.play_stop()
>>> audio.play_start("/t/2.amr",15)
>>> audio.play_stop()
>>> audio.play_start("/t/2.amr",15)
>>>
you can't record after answer a call:
>>> cellular.answer()
>>> audio.record_start("/t/2.amr")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: cannot record audio file
but you can start record before answer it record only sound from mic, not the caller voice
>>> audio.record_start("/t/2.amr")
>>> cellular.answer()
>>> audio.record_stop()
To get sound, you need only to solder two wires from old headphone to spk_n , spk_p :
https://raw.githubusercontent.com/Ai-Thinker-Open/GPRS_C_SDK/master/doc/assets/pudding_pin.png
If there is a way to send sound to the caller , that will be a great addition to control device with DTMF
The audio output seems to be working for AUDIO_MODE_HANDSET and AUDIO_MODE_LOUDSPEAKER (1,2), both on the speaker pins, not very sure but the only difference I could appreciate is maybe that LOUDSPEAKER is a little louder than HANDSET?
there are a bug, when audio.play_start no existed file, you must run audio.play_stop() first
>>> audio.play_start("/t/no_existe_file.amr",15) Traceback (most recent call last): File "<stdin>", line 1, in <module> ValueError: cannot play audio file >>> audio.play_start("/t/2.amr",15) Traceback (most recent call last): File "<stdin>", line 1, in <module> ValueError: cannot play audio file >>> audio.play_stop() >>> audio.play_start("/t/2.amr",15) >>> audio.play_stop() >>> audio.play_start("/t/2.amr",15) >>>
yep, AUDIO_Stop() missing in case AUDIO_Play return error.
Can you give more details on this? Did you test it? What formats it supports? Where does it output sound? Can you play it as a voice mail?
I am testing with AMR122 and it seems to be working fine both for recording and playing, also mp3 playing seems to be working fine (but not recording). As per the voice mail if you mean like an answering machine I think it will not work as it seems to be not supporting audio recording/playing during a call, not even on official AT command set.
It seems like we have audio APIs here and there. I do understand the limitations of the SDK but it would be nice if we invent something compatible.
I have been checking the AMP audio skin, didn't know about the other one but they seem to be more focusing on tone generation, my idea was to implement the basic support and leave the rest to Python, I am coming from Lua so very very new to Python but I was thinking that maybe we could add a generic audio.play, audio.pause, audio.resume, audio.record support at module level (I mean already in Python in place then C)?
Would it make sense maybe to move the audio support at the moment inside modcellular.c as it is specific to this board only?