@@ -414,50 +414,19 @@ where
414414
415415 /// Sets the buffer size for the input.
416416 ///
417- /// To record sound without any glitches the audio card/chip must always
418- /// have a place to put a newly recorded sample. Unfortunately some samples
419- /// might take longer to consume then others. For example because the OS
420- /// preempts the thread running the microphone input. This happens more
421- /// often if the computer is under high load. That is why the OS has an
422- /// input buffer. This governs the size of that buffer.
417+ /// This has no impact on latency, though a too small buffer can lead to audio
418+ /// artifacts if your program can not get samples out of the buffer before they
419+ /// get overridden again.
423420 ///
424- /// Note there is a large buffer between the thread running the microphone
425- /// input and the rest of rodio. Short slowdowns in audio processing in
426- /// your rodio code will not easily cause us to miss samples.
427- ///
428- /// Rodio only gets the new samples once the OS swaps its buffer. That
429- /// means there is a minimum delay (latency) of `<buffer
430- /// size>/<sample_rate*channel_count>` seconds before a sample is made
431- /// available to Rodio.
432- ///
433- /// # Large vs Small buffer
434- /// - A larger buffer size results in high latency. This can be an issue
435- /// for voip and other real time applications.
436- /// - A small buffer might cause:
437- /// - Higher CPU usage
438- /// - Recording interruptions such as buffer underruns.
439- /// - Rodio to log errors like: `alsa::poll() returned POLLERR`
440- ///
441- /// # Recommendation
442- /// If low latency is important to you consider offering the user a method
443- /// to find the minimum buffer size that works well on their system under
444- /// expected conditions. A good example of this approach can be seen in
445- /// [mumble](https://www.mumble.info/documentation/user/audio-settings/)
446- /// (specifically the *Output Delay* & *Jitter buffer*.
447- ///
448- /// These are some typical values that are a good starting point. They may also
449- /// break audio completely, it depends on the system.
450- /// - Low-latency (audio production, live monitoring): 512-1024
451- /// - General use (games, media playback): 1024-2048
452- /// - Stability-focused (background music, non-interactive): 2048-4096
421+ /// Normally the default input config will have this set up correctly.
453422 ///
454423 /// # Example
455424 /// ```no_run
456425 /// # use rodio::microphone::MicrophoneBuilder;
457426 /// let builder = MicrophoneBuilder::new()
458427 /// .default_device()?
459428 /// .default_config()?
460- /// .try_buffer_size(1024 )?;
429+ /// .try_buffer_size(4096 )?;
461430 /// # Ok::<(), Box<dyn std::error::Error>>(())
462431 /// ```
463432 pub fn try_buffer_size (
@@ -497,8 +466,8 @@ where
497466 /// // We want mono, if thats not possible give
498467 /// // us the lowest channel count
499468 /// .prefer_buffer_sizes([
500- /// 512 .try_into().expect("not zero"),
501- /// 1024 .try_into().expect("not_zero"),
469+ /// 2048 .try_into().expect("not zero"),
470+ /// 4096 .try_into().expect("not_zero"),
502471 /// ]);
503472 /// # Ok::<(), Box<dyn std::error::Error>>(())
504473 /// ```
@@ -511,7 +480,7 @@ where
511480 /// .default_config()?
512481 /// // We want mono, if thats not possible give
513482 /// // us the lowest channel count
514- /// .prefer_buffer_sizes(512 ..);
483+ /// .prefer_buffer_sizes(4096 ..);
515484 /// # Ok::<(), Box<dyn std::error::Error>>(())
516485 /// ```
517486 pub fn prefer_buffer_sizes (
0 commit comments