Audio Sink: Difference between revisions

From GNU Radio
Jump to navigation Jump to search
No edit summary
(→‎Linux: Add more details)
 
(8 intermediate revisions by 2 users not shown)
Line 1: Line 1:
[[Category:Block Docs]]
[[Category:Block Docs]]
Allows a signal to be played through your speakers or other audio device
Allows a signal to be played through your speakers or other audio device


== Parameters ==
== Parameters ==


; Sample Rate
=== Sample Rate ===
: Audio sampling rate used, click the drop-down menu to see popular rates.  Note, not all sampling rates will be supported by your hardware. For typical applications, this should be set to 48kHz.  
 
To set the Audio sampling rate, click the drop-down menu to see popular rates.  Note: not all sampling rates will be supported by your hardware. For typical applications, this should be set to 48kHz.  
 
=== Device Name ===
 
Leave the device name blank to choose the default audio device. Selecting a specific device name depends on the OS.
 
==== OSX ====
 
On OSX, go into the System Preferences, click on "Sound", and then the "Output" tab. The listings under "Name" contain the exact device names currently available; if a new audio device is attached to the computer then a new name will appear -- for example "Headphones" for some Macs. Since most such device names contain spaces, make sure to put quotes around the name argument, for example:
 
    spectrum_inversion.py -O "MacBook Pro Speakers"
 
==== Linux ====
 
On Linux, the device is selected via ALSA, where typical choices include:
* <code>default</code> (selected if left empty)
:This will use the default device. Note that in most desktop systems this is actually managed by PipeWire or PulseAudio, to check this, you can execute <code>aplay -L | grep -A1 ^default</code>.
* <code>hw:0,0</code>
:This will select the hardware card 0, device 0. To check the list of available cards/devices, issue the command <code>aplay -l</code> (note that <code>-l</code> is lower case here).
* <code>plughw:0,0</code>
:This is the same as <code>hw:0,0</code> but enables software processing, which allows e.g. selecting a sample rate not natively supported by the sound card.
* <code>pipewire</code> (to explicitly use PipeWire)
* <code>pulse</code> (to explicitly use PulseAudio)
 
 
 
For ALSA users with audio trouble, follow this procedure:
* from a terminal window enter:
<code>aplay -L</code>
* find the desired entry such as:
<pre>
hw:CARD=Generic,DEV=0
    HD-Audio Generic, ALC662 rev3 Analog
    Direct hardware device without any conversions
</pre>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from the list which matches your device. To use an HDMI monitor with speakers, find an appropriate entry with "HDMI" in it.
* use the first line of that entry (e.g. "hw:CARD=Generic,DEV=0") as the device name. Unless the name has spaces in it, the quotes are optional.
 
* For issues or debugging, see [[ALSAPulseAudio]].
 
==== Windows ====
 
On Windows, go into the Settings, cllck on "System", click on "Sound", and then the "Output" tab. The listings under "Name" contain the exact device names currently available; if a new audio device is attached to the computer then a new name will appear, for example "Headphones". Since most of the device names contain spaces, make sure to put quotes around the name argument, for example:


; Device Name
    "Speakers (Realtek High Definition Audio)"
: Leave the device name blank to choose default audio device. ALSA users with audio trouble may try setting the device name to plughw:0,0


; OK to Block
=== OK to Block ===
: On by default, which should be used when the source is not throttled, e.g. generating a signal within GNU Radio or reading it from a file, meaning the audio sink has to be responsible for deciding when it's time to take more samples.  If it's set to Off, then the Audio Sink will discard samples rather than the internal buffers filling up and causing the RF source block to have to discard them instead.


; Num Inputs
On by default, which should be used when this sink is not throttled by any other block.
: The audio sink can have multiple inputs depending upon your hardware. For example, set the inputs to 2 for stereo audio, or 1 for mono.


For issues or debugging see https://wiki.gnuradio.org/index.php/ALSAPulseAudio
=== Num Inputs ===
The audio sink can have multiple inputs depending upon your hardware. For example, set the inputs to 2 for stereo or 1 for mono.


== Example Flowgraph ==
== Example Flowgraph ==

Latest revision as of 16:12, 13 January 2022


Allows a signal to be played through your speakers or other audio device

Parameters

Sample Rate

To set the Audio sampling rate, click the drop-down menu to see popular rates. Note: not all sampling rates will be supported by your hardware. For typical applications, this should be set to 48kHz.

Device Name

Leave the device name blank to choose the default audio device. Selecting a specific device name depends on the OS.

OSX

On OSX, go into the System Preferences, click on "Sound", and then the "Output" tab. The listings under "Name" contain the exact device names currently available; if a new audio device is attached to the computer then a new name will appear -- for example "Headphones" for some Macs. Since most such device names contain spaces, make sure to put quotes around the name argument, for example:

   spectrum_inversion.py -O "MacBook Pro Speakers"

Linux

On Linux, the device is selected via ALSA, where typical choices include:

  • default (selected if left empty)
This will use the default device. Note that in most desktop systems this is actually managed by PipeWire or PulseAudio, to check this, you can execute aplay -L | grep -A1 ^default.
  • hw:0,0
This will select the hardware card 0, device 0. To check the list of available cards/devices, issue the command aplay -l (note that -l is lower case here).
  • plughw:0,0
This is the same as hw:0,0 but enables software processing, which allows e.g. selecting a sample rate not natively supported by the sound card.
  • pipewire (to explicitly use PipeWire)
  • pulse (to explicitly use PulseAudio)


For ALSA users with audio trouble, follow this procedure:

  • from a terminal window enter:

aplay -L

  • find the desired entry such as:
hw:CARD=Generic,DEV=0
    HD-Audio Generic, ALC662 rev3 Analog
    Direct hardware device without any conversions

      from the list which matches your device. To use an HDMI monitor with speakers, find an appropriate entry with "HDMI" in it.

  • use the first line of that entry (e.g. "hw:CARD=Generic,DEV=0") as the device name. Unless the name has spaces in it, the quotes are optional.

Windows

On Windows, go into the Settings, cllck on "System", click on "Sound", and then the "Output" tab. The listings under "Name" contain the exact device names currently available; if a new audio device is attached to the computer then a new name will appear, for example "Headphones". Since most of the device names contain spaces, make sure to put quotes around the name argument, for example:

   "Speakers (Realtek High Definition Audio)"

OK to Block

On by default, which should be used when this sink is not throttled by any other block.

Num Inputs

The audio sink can have multiple inputs depending upon your hardware. For example, set the inputs to 2 for stereo or 1 for mono.

Example Flowgraph

This flowgraph should play a 1 kHz tone out of your speakers. Note that you don't need a throttle block, the Audio Sink should throttle for you. If you do end up using an already-throttled signal source, then set "OK to Block" to No.

Audio-sink-ex.png