Skip to content

instruments.soundcard

Jack Sankey edited this page Aug 27, 2020 · 6 revisions

Getting Started

mcphysics.instruments.soundcard provides a scriptable graphical user interface for any soundcards connected to your system. To create an instance,

import mcphysics
sc = mcphysics.instruments.soundcard()

This should pop up a window that looks something like this:

soundcard.png

Along the top you will can choose the input and output devices and sampling rates. These lists are populated from the operating system, and not all combinations are allowed, so pay attention to the console output for errors. Once you find the right devices, you can press "Record" to collect data ("Input" tab), "Play" to send a waveform to the output ("Output" tab), and "Record+Play" to do both simultaneously.

Beyond this, the workflow is nearly identical to that of adalm2000, except that this system is streaming, so it's possible to collect multiple data sets without missing a single data point; this can be done with the trigger mode in "Continuous" or triggered with "Stay Triggered" checked. If incoming data is missed, "Overflow" will check, and if the output buffer has a glitch, "Underflow" will check.

The following tabs are included in soundcard():

  • "Input" (sc.tab_in): This is very similar to that of sillyscope or adalm2000, comprising

    • sc.tab_in.settings: input settings and trigger options on the left
    • sc.data_processor: a data_processor (sc.data_processor) object for manipulating incoming data on the right.
  • "Output" (sc.tab_out): Waveform Designer (sc.waveform_designer) object for creating output waveforms.

  • "Quadratures" (sc.tab_quad): Quadratures object (sc.quadratures) for measuring quadratures and performing frequency sweeps.

Scripting

All actions that you can manually perform can be scripted. For example, to press the "Play" button:

sc.button_play.set_checked(True) # Shorthand: sc.button_play(True)

To get the state of the record button:

sc.button_record.is_checked() # Shorthand: sc.button_record()

To set the number of iterations to 20 and trigger level to 0.1:

sc.tab_in.settings['Iterations'] = 20
sc.tab_in.settings['Trigger/Level'] = 0.1

You should be able to find every control using code completion, and to aid in these efforts, we have put objects contained within the input tab under sc.tab_in, within the output tab under sc.tab_out, and within the quadratures tab under sc.tab_quad. All number boxes start with number_, all buttons start with button_, and (Tree Dictionaries)[https://github.com/Spinmob/spinmob/wiki/6.-Easy-GUI-Generator-(egg)#tree-dictionaries] are called settings.