question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[enh] PCM stream should convert to List<int>

See original GitHub issue

Hi,

I am trying to stream in near-realtime from the recorder (mic) to the player(headsets) - like many people, it seems 😃. I started from the streamLoop example, easy and cool.

My next-step: to add the processing in the middle. I take the uint8list from buffer.data and after converting to int16list I do the processing on it and back. I tried to use Codec.pcm16WAV, reason: when using Codec.pcm16, the processing itself in the middle works fine but in the headsets I got only a terrible ?white? noise mixed with silence. I really have no idea about the reasons…

I know the processing step itself is ok, and I think that it should work fine with pcm16WAV. I don’t know why with Codec.pcm16 I get this very -strange- behavior… I did a test with a classic wav file recorded from the phone but not with this library, and processing+playing worked without issues… but I would need to do the same in real-time with the stream.

I attach a mediainfo report of the file that worked with (played correctly from assets, with the processing in the middle):


Format                                   : Wave
File size                                : 175 KiB
Duration                                 : 4 s 63 ms
Overall bit rate mode                    : Constant
Overall bit rate                         : 353 kb/s
Format                                   : PCM
Format settings                          : Little / Signed
Codec ID                                 : 1
Duration                                 : 4 s 63 ms
Bit rate mode                            : Constant
Bit rate                                 : 352.8 kb/s
Channel(s)                               : 1 channel
Sampling rate                            : 22.05 kHz
Bit depth                                : 16 bits
Stream size                              : 175 KiB (100%)

I opened this file with basic code+minor mods of liveplayback.dart, with codec.pcm16(!) set to the player. This last result confused me.

After a bunch of shady errors I found that the record-to-stream feature is available only for pcm16 (nice to have: a 2words-note about that in the docs in that section, didn’t find any!). I don’t know why the app did not throw the exception in the flutter_sound_recorder.dart (245):

    if (toStream != null && codec != Codec.pcm16)
      throw Exception ('toStream can only be used with codec == Codec.pcm16');

Error I got instead (partial):

E/flutter (32427): [ERROR:flutter/lib/ui/ui_dart_state.cc(177)] Unhandled Exception: PlatformException(ERR_UNKNOWN, ERR_UNKNOWN, startPlayer() error, null) E/flutter (32427): #0 StandardMethodCodec.decodeEnvelope package:flutter/…/services/message_codecs.dart:582 E/flutter (32427): #1 MethodChannel._invokeMethod package:flutter/…/services/platform_channel.dart:159 E/flutter (…

Why there is such ‘limit’ on the codec when using record-to-stream? Do you think there’s any way to fix/improve that by library’s side? Do you have any suggestion for this use case?

Thanks

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:12

github_iconTop GitHub Comments

2reactions
Larpouxcommented, Aug 31, 2021

Yes, I agree with you : StartRecorder should return :

  • Uint16List for PCM-Linear 16
  • Uint8List for PCM-linear 8
  • and List < float > for PCM Float32

I am currently working on an upgrade of the Flutter Sound API. It will be Flutter Sound Version 9.0.x

With this new version, I want to implement various PCM format (mono/stereo, 8/16 bits width, little/big endian, integer/float). And the App will receive a correct List < something >

I cannot say when this new API will be released. Probably I will release a beta version during september.

1reaction
ebelevicscommented, Jun 9, 2021

I’m also trying understand why as a stream we do receive Uint8List instead of Uint16List as we are using pcm16 with 16bit depth. My first thought was maybe Uint16 is split into two Uint8, but it was not the case with combining two Uint8 values as recorded audio on playback got two times faster.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Introducing Private Click Measurement, PCM - WebKit
This blog post covers a new feature called Private Click Measurement, or PCM, for measuring ad clicks across websites and from iOS apps...
Read more >
PCm - River Thames Conditions
The subject is jazz swing, Islamic online university bangladesh, ... Must watch video on youtube, Jd spielman star tribune, Cotto e bruciato, ...
Read more >
FFmpeg
A complete, cross-platform solution to record, convert and stream audio and video ... ClearVideo decoder (partial); 16.8 and 24.0 floating point PCM decoder ......
Read more >
January 25, 2021
Initial changes to generators should be applied in power flow. 1. DC line flow/direction. 1. rectifier, inverter (alpha, gama). Already fixed I PCM....
Read more >
The BBC PCM / NICAM Story - BBCeng.info
So the arrival of PCM would have a bigger audible impact for those using ... There was also a '14th channel' – i.e....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found