[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Discuss-gnuradio] Audio data types
From: |
Eric Blossom |
Subject: |
Re: [Discuss-gnuradio] Audio data types |
Date: |
Wed, 13 Jul 2005 14:22:25 -0700 |
User-agent: |
Mutt/1.5.6i |
On Wed, Jul 13, 2005 at 02:42:52PM -0600, David R. Palchak wrote:
> Is there currently anything like an audio.source_s() block
> that produces 16-bit samples at a specified rate? If not,
> how might one go about implementing such a block using the
> existing audio code?
>
> Thanks,
> David Palchak
Here's a block that will handle a single (mono) output stream.
from gnuradio import gr
from gnuradio import audio
class audio_source_s(gr.hier_block):
"""
audio source that produces a single stream of shorts
"""
def __init__(self, fg, sample_rate, pcm_device=""):
"""
@param fg: flow_graph
@param sample_rate: audio sample rate
@param pcm_device: optional audio device name, e.g., hw:0,0 or
/dev/dsp
"""
src = audio.source(sample_rate, pcm_device)
scale = gr.multiply_const_ff(32768.0)
f2s = gr.float_to_short()
fg.connect(src, scale, f2s)
gr.hier_block.__init__(self, fg, src, f2s)