Skip to content
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

Mic and speaker update #70

Merged
merged 6 commits into from
Feb 13, 2024
Merged

Mic and speaker update #70

merged 6 commits into from
Feb 13, 2024

Conversation

danilo-pejovic
Copy link
Collaborator

@danilo-pejovic danilo-pejovic commented Feb 12, 2024

  • Adds ability to stop recording via service call (timeout of 30 seconds otherwise).

  • Adds ability for speaker node to play wav files.

  • Changes "mp3_file" request variable from PlayAudio service call as it no longer makes sense (as it can both play wav and mp3), updates lifecycle manager and rae_sdk to account for that.

  • Adding gain to wav file playing to account for bit quieter recording.

  • Update for pcm params for mp3 playing to use relevant channels better.

  • Added a dead zone for motors to not confuse PID controller on low speeds. Should solve RAE moving when command to stop is given.

snd_pcm_set_params(alsaHandle, SND_PCM_FORMAT_S16_LE, SND_PCM_ACCESS_RW_INTERLEAVED, 1, rate * channels, 2, 50000);


snd_pcm_set_params(alsaHandle, SND_PCM_FORMAT_S16_LE, SND_PCM_ACCESS_RW_INTERLEAVED, channels, rate, 2, 50000);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Won't this cause issues?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Issue was bit further down the code in:

if(snd_pcm_writei(alsaHandle, buffer, buffer_size/2 < 0) where I was sending too big chunk of a buffer. To compensate for that I only let alsa run in 1 channel. I further divided buffer into individual bytes when sending to device and now it runs without issues in both stereo and mono files.

@Serafadam
Copy link
Collaborator

Other than the comment, LGTM, formatting needs to be fixed.

@danilo-pejovic
Copy link
Collaborator Author

@Serafadam I further added low pass filter to mic node to remove (most of the) noise from recording. You can check out that change and if everything looks ok, you can merge.

@Serafadam Serafadam merged commit f411d26 into humble Feb 13, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants