saveAsGen23

Contents

saveAsGen23#

csoundengine.csoundlib.saveAsGen23(data, outfile, fmt='%.12f', header='')[source]#

Saves the data to a gen23 table

Note

gen23 is a 1D list of numbers in text format, sepparated by a space

Parameters:
  • data (Union[Sequence[float], ndarray]) – A 1D sequence (list or array) of floats

  • outfile (str) – The path to save the data to. Recommended extension: ‘.gen23’

  • fmt – If saving frequency tables, fmt can be “%.1f” and save space, for amplitude the default if “%.12f” is best

  • header – If specified it is included as a comment as the first line (csound will skip it). It is there just to document what is in the table

Return type:

None

Example

import bpf4
from csoundengine import csoundlib
a = bpf.linear(0, 0, 1, 10, 2, 300)
dt = 0.01
csoundlib.saveAsGen23(a[::dt].ys, "out.gen23", header=f"dt={dt}")

In csound:

gi_tab ftgen 0, 0, 0, -23, "out.gen23"

instr 1
  itotaldur = ftlen(gi_tab) * 0.01
  ay poscil 1, 1/itotaldur, gi_tab
endin