Recommended application for converting mathematical signal to sound

id flag

I use Ubuntu 22.04. Is there an application for converting mathematical periodical sin/cos formula (functions) to sound? For example is there a way for playing these signals:

  • cos(2π · 440 t)
  • cos t + cos 2^(1/2) t


  • I only look for free applications.


  • I have installed FFmpeg version 4.4.2 and GNU Octave, version 6.4.0 on my machine and instructions or web page which describes the way of using those for my purpose is acceptable.
ca flag
  1. Create a file with "samples" from your formulas.
    Simple "C" or Python scripting will do the thing, unless Octave itself has means for it.
  2. Install Audacity
  3. Menu: File > Import > ... your sample-file.

Some Python -code to play with...
$ cat 
#!/bin/env python

import math, sys

# trick to make CSI, ESC[ - sequences work in Windows-stupid-CMD.EXE to activate "ANSI.SYS" (as in old MS-DOS)
import os;os.system("");CSI='\x9B' # terminfo, curses, "ANSI" terminal expected

sps=44100       # sample rate, 44100 for "CD"-like
et=10           # end time, seconds
res=2**16-10        # max value for samples, UNSIGNED, < base-two-binary-max.
halfres=(res)/2     # adjust for SIGNED, Because*sin()/cos() [-1,1]

Hz=440          # base frequency, at least for simple cos or sin


length = math.ceil(math.log(res, 256)) # bytes per sample
sys.stderr.write(str(length)+' bytes /sample\n\n')

for t in range(int(et*sps)): # "t" in "samples"
  #> cos t + cos 2^(1/2) t  # note: cos()+cos() may reach [-2,2], so scaled to half.
  #s=int(( math.cos( 2*pi*timespot )+math.cos(1.414*timpespot) )/2*halfres)
  #> cos(2π · 440 t)
  s=int(math.cos( 2*pi*timespot )*halfres)
  if s>top:
  elif s<bot:
  f.write( int.to_bytes(s, length=length, byteorder='big', signed=True) )

print(f'{CSI}AValues: top; {top}, bottom; {bot}{CSI}J')
id flag
Thank you for your reply. I prefer using `Audacity`, at least for experimental usages. Can you provide a link for the syntax for writing complex formula as `raw data` in sample file?
Hannu avatar
ca flag
My recommendation: Look up a tutorial on python programming, then look into what I have included above - you will probably need just a few hours of Python-study.
I sit in a Tesla and translated this thread with Ai:


Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.