sound#

class perceptivo.types.sound.Audio_Config(fs: int = 44100)#

Bases: object

Base class for audio configuration

Params:

fs (int): Sampling rate in Hz, default 44100

fs: int = 44100#
class perceptivo.types.sound.Jackd_Config(fs: int = 44100, bin: pathlib.Path = <factory>, priority: int = 75, driver: str = 'alsa', device_name: typing.Union[str, int] = 'hw:sndrpihifiberry', nperiods: int = 3, period: int = 1024, playback_only: bool = True, outchannels: list = <factory>)#

Bases: perceptivo.types.sound.Audio_Config

Configure the jackd daemon used by the sound server, see https://linux.die.net/man/1/jackd

Params:

bin (pathlib.Path): Path to the jackd binary priority (int): Priority to run the process (higher is better), default 75 driver (str): Driver to use, default ‘alsa’ device_name (str, int): Device to use in alsa’s parlance, default ‘hw:sndrpihifiberry’.

Also accepts ints for use with coreaudio

nperiods (int): Number of periods per buffer cycle, default 3 period (int): size of period, default 1024 samples. launch_str (str): launch string with arguments compiled from the other arguments

bin: pathlib.Path#
priority: int = 75#
driver: str = 'alsa'#
device_name: Union[str, int] = 'hw:sndrpihifiberry'#
nperiods: int = 3#
period: int = 1024#
playback_only: bool = True#
outchannels: list#
property launch_str: str#
pydantic model perceptivo.types.sound.Sound#

Bases: pydantic.main.BaseModel

Parameterization of an abstract probe sound

Parameters
  • frequency (float) – Frequency in Hz

  • amplitude (float) – Amplitude in dbSPL

  • duration (float) – Duration of sound in seconds

Variables

uuid (str) – Unique UUID to identify sounds

Create a new model by parsing and validating input data from keyword arguments.

Raises ValidationError if the input data cannot be parsed to form a valid model.

Show JSON schema
{
   "title": "Sound",
   "description": "Parameterization of an abstract probe sound\n\nArgs:\n    frequency (float): Frequency in Hz\n    amplitude (float): Amplitude in dbSPL\n    duration (float): Duration of sound in seconds\n\nAttributes:\n    uuid (str): Unique UUID to identify sounds",
   "type": "object",
   "properties": {
      "frequency": {
         "title": "Frequency",
         "type": "number"
      },
      "amplitude": {
         "title": "Amplitude",
         "type": "number"
      },
      "duration": {
         "title": "Duration",
         "default": 0.5,
         "type": "number"
      },
      "sound_type": {
         "title": "Sound Type",
         "default": "Gammatone",
         "enum": [
            "Gammatone"
         ],
         "type": "string"
      },
      "timestamp": {
         "title": "Timestamp",
         "type": "string",
         "format": "date-time"
      },
      "jack_client": {
         "title": "Jack Client"
      },
      "uuid": {
         "title": "Uuid",
         "type": "string"
      }
   },
   "required": [
      "frequency",
      "amplitude"
   ]
}

Config
  • arbitrary_types_allowed: bool = True

Fields
field frequency: float [Required]#
field amplitude: float [Required]#
field duration: float = 0.5#
field sound_type: Literal['Gammatone'] = 'Gammatone'#
field timestamp: Optional[datetime.datetime] = None#
field jack_client: Optional[JackClient] = None#
field uuid: str [Optional]#
stamp_time()#

Record the time that the sound is played in Sound.timestamp

property sound_kwargs: dict#

Sound kwargs that the sound class accepts

(ie. filtering out sound_type and others the sound class doesn’t take)

Returns

dict of arguments

property sound_class: autopilot.stim.sound.base.Sound#

The sound class that corresponds to the sound_type retrieved from the perceptivo.sound.sounds module.

Returns

autopilot.stim.sound.sounds.Jack_Sound - The sound class!