-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
preliminary audio support #76
base: master
Are you sure you want to change the base?
Conversation
ports/gprs_a9/modaudio.c
Outdated
while(--timeout) | ||
{ | ||
Trace(1,"recording"); | ||
OS_Sleep(1000); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be better not to make sleep here. It will block the python main thread and won’t allow any callbacks to run until recording finishes. I would run it in another thread ( task). It’s also applies to the play function
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, play doesn't need the sleep at all indeed and the record timeout could be managed with the data callback from AUDIO_RecordStart.
Should I send a new pull request or should I wait for this to be merged first?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, I have renamed audio_record to audio_record_start and audio_play to audio_play_start and removed any sleep so we can manage timeout and any other kind of interaction directly from python.
No idea yet on how to pass the fileFd to AUDIO_Resume() so it is commented out at the moment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested it, and works fine ^^
I changed args to 4 to play mp3 files.
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(modaudio_play_start_obj, 1, 4, modaudio_play_start);
import audio
audio.play_start("/t/099-Az-zalzala.mp3",15,2,5) # AUDIO_TYPE_MP3 = 5
audio.play_stop()
…lay_start and record_start
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. |
there are a bug, when audio.play_start no existed file, you must run audio.play_stop() first
you can't record after answer a call:
but you can start record before answer
|
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? |
yep, AUDIO_Stop() missing in case AUDIO_Play return error. |
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. |
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? |
Hello everyone and thank you for the great job done so far! :)