Browse Source

parametrize audio sample rate

Fabian Peter Hammerle 3 years ago
parent
commit
f13280365e
2 changed files with 29 additions and 10 deletions
  1. 20 8
      fm_radio.grc
  2. 9 2
      fm_radio.py

+ 20 - 8
fm_radio.grc

@@ -32,6 +32,18 @@ options:
     state: enabled
 
 blocks:
+- name: audio_sample_rate_hertz
+  id: variable
+  parameters:
+    comment: ''
+    value: '48000'
+  states:
+    bus_sink: false
+    bus_source: false
+    bus_structure: null
+    coordinate: [1105, 404]
+    rotation: 0
+    state: true
 - name: channel_width_hertz
   id: variable
   parameters:
@@ -95,7 +107,7 @@ blocks:
     bus_sink: false
     bus_source: false
     bus_structure: null
-    coordinate: [1551, 545]
+    coordinate: [1563, 545]
     rotation: 0
     state: true
 - name: analog_wfm_rcv_0
@@ -112,7 +124,7 @@ blocks:
     bus_sink: false
     bus_source: false
     bus_structure: null
-    coordinate: [1087, 261]
+    coordinate: [1100, 261]
     rotation: 0
     state: enabled
 - name: audio_sink_0
@@ -124,12 +136,12 @@ blocks:
     device_name: ''
     num_inputs: '1'
     ok_to_block: 'True'
-    samp_rate: '48000'
+    samp_rate: audio_sample_rate_hertz
   states:
     bus_sink: false
     bus_source: false
     bus_structure: null
-    coordinate: [1178, 479]
+    coordinate: [1156, 503]
     rotation: 180
     state: enabled
 - name: blocks_multiply_const_vxx_0
@@ -147,7 +159,7 @@ blocks:
     bus_sink: false
     bus_source: false
     bus_structure: null
-    coordinate: [1582, 479]
+    coordinate: [1594, 479]
     rotation: 180
     state: true
 - name: low_pass_filter_0
@@ -251,7 +263,7 @@ blocks:
     bus_sink: false
     bus_source: false
     bus_structure: null
-    coordinate: [1559, 111]
+    coordinate: [1578, 111]
     rotation: 0
     state: true
 - name: qtgui_waterfall_sink_x_0
@@ -323,7 +335,7 @@ blocks:
     comment: ''
     decim: channel_width_hertz
     fbw: '0'
-    interp: '48000'
+    interp: audio_sample_rate_hertz
     maxoutbuf: '0'
     minoutbuf: '0'
     taps: ''
@@ -332,7 +344,7 @@ blocks:
     bus_sink: false
     bus_source: false
     bus_structure: null
-    coordinate: [1560, 289]
+    coordinate: [1576, 292]
     rotation: 0
     state: true
 - name: rtlsdr_source_0

+ 9 - 2
fm_radio.py

@@ -79,6 +79,7 @@ class fm_radio(gr.top_block, Qt.QWidget):
         self.samp_rate = samp_rate = 2560000
         self.frequency_mhz = frequency_mhz = 98.3
         self.channel_width_hertz = channel_width_hertz = 250000
+        self.audio_sample_rate_hertz = audio_sample_rate_hertz = 48000
 
         ##################################################
         # Blocks
@@ -102,7 +103,7 @@ class fm_radio(gr.top_block, Qt.QWidget):
         self.rtlsdr_source_0.set_antenna('', 0)
         self.rtlsdr_source_0.set_bandwidth(0, 0)
         self.rational_resampler_xxx_0 = filter.rational_resampler_fff(
-                interpolation=48000,
+                interpolation=audio_sample_rate_hertz,
                 decimation=channel_width_hertz,
                 taps=None,
                 fractional_bw=None)
@@ -191,7 +192,7 @@ class fm_radio(gr.top_block, Qt.QWidget):
                 firdes.WIN_KAISER,
                 6.76))
         self.blocks_multiply_const_vxx_0 = blocks.multiply_const_ff(volume)
-        self.audio_sink_0 = audio.sink(48000, '', True)
+        self.audio_sink_0 = audio.sink(audio_sample_rate_hertz, '', True)
         self.analog_wfm_rcv_0 = analog.wfm_rcv(
         	quad_rate=channel_width_hertz,
         	audio_decimation=1,
@@ -246,6 +247,12 @@ class fm_radio(gr.top_block, Qt.QWidget):
         self.channel_width_hertz = channel_width_hertz
         self.qtgui_freq_sink_x_0.set_frequency_range(0, self.channel_width_hertz)
 
+    def get_audio_sample_rate_hertz(self):
+        return self.audio_sample_rate_hertz
+
+    def set_audio_sample_rate_hertz(self, audio_sample_rate_hertz):
+        self.audio_sample_rate_hertz = audio_sample_rate_hertz
+
 
 
 def main(top_block_cls=fm_radio, options=None):