Audio Source / Sink



Source
Usage:
	src = gr.audio_source (int sampling_rate)
Example:
	sampl_freq = 32e3
	audio_jack_in = gr.audio_source(sampl_freq)
uses line-in etc as signal source at 32K samples-per-second.




Sink
Usage:
	dst = gr.audio_sink (int sampling_rate)
Example:
	sound_out = gr.audio_sink(22000)
will output to sound card at 22Khz sampling rate.




Example - the following will sound a US dialtone with a touch of line hiss. It creates two signals at 350 and 440Hz, adds them together with a little gaussian noise then sends it to your sound card.

#!/usr/bin/env python
#
# Copyright 2004 Free Software Foundation, Inc.
# 
# This file is part of GNU Radio
# 
# GNU Radio is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
# 
# GNU Radio is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public License
# along with GNU Radio; see the file COPYING.  If not, write to
# the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
# Boston, MA 02111-1307, USA.
# 

from gnuradio import gr
from gnuradio import audio

def build_graph ():
    sampling_freq = 48000
    ampl = 0.1

    fg = gr.flow_graph ()
    src0 = gr.sig_source_f (sampling_freq, gr.GR_SIN_WAVE, 350, ampl)
    src1 = gr.sig_source_f (sampling_freq, gr.GR_SIN_WAVE, 440, ampl)
    noise = gr.noise_source_f (gr.GR_GAUSSIAN, 0.001, 3829)
    sum = gr.add_ff ()
    dst = gr.audio_sink (sampling_freq)
    fg.connect ( (src0, 0), (sum, 0))
    fg.connect ( (src1, 0), (sum, 1))
    fg.connect ( (noise, 0), (sum, 2))
    fg.connect ( (sum, 0), (dst, 0) )

    return fg

if __name__ == '__main__':
    fg = build_graph ()
    fg.start ()
    raw_input ('Press Enter to quit: ')
    fg.stop ()