How would I generating a Sox Synthesized sound similar to an alarm bell

934 Views Asked by At

I am trying to generate a sound using the sox package synth feature, alarm 1: https://soundcloud.com/xekons/a1-1 and alarm 2: https://soundcloud.com/xekons/a2-1

its possible to create some interesting sounds:

play -q -n synth 0.2 sine 480 vol 0.2
play -q -n synth 0.2 triangle 480 vol 0.2
play -q -n synth 0.2 square 480 vol 0.2
play -q -n synth 0.2 pluck 480 vol 0.2
play -q -n synth 0.2 pluck C5 vol 0.2
play -q -n synth 0.2 sawtooth 480 vol 0.2
play -q -n synth 0.2 trapezium 480 vol 0.2
play -q -n synth 0.2 exp 480 vol 0.2

Here is a very elaborate one I found online:

play -n synth pl G2 pl B2 pl D3 pl G3 pl D4 pl G4 delay 0 .05 .1 .15 .2 .25 remix - fade 0 4 .1 norm -1

To listen to the alarm wave file it seems like its a decreasing volume, but maybe also frequency?

I tried this:

play -q -n synth 0.6 triangle 1500-1300 vol 0.2

which changes the frequency, but beyond that it sounds nothing like the bell lol. Also not looking for a close match, just something sounding somewhat similar to the bell in those wav files I linked.

The sox synthesized sound will be used in the python script that I am writing, and will go off under certain conditions. I plan to make the entire project I am working on opensource once I polish it up a bit.

2

There are 2 best solutions below

0
On

I could not figure out how to synthesize the sounds, I really wish I understood the synthesizer better.

for now I am just playing the files directly from my python script, here is a small snippet:

#!/usr/bin/env python3
import serial, time, sox, psycopg2

tfm = sox.Transformer()  #initialize sox playback

tfm.preview("/wav/a2.wav") #play alarm 2 wav file

If anyone can synthesize any sounds remotely similar to the ones I linked, please do post, and I will update this to mark your answer as the correct one. THANK YOU!

0
On

When listening to the 'alarm' sound, you hear a constant frequency, with the volume gradually going down. The decreasing volume is easily achieved by fading out.

play -n synth 3 sin 960 fade l 0 3 2.8

Explanation:

  • synth 3: take plenty of time (here: 3 seconds) to allow fade to slowly decrease the volume. If the result turns out to be too long, then you can always trim afterwards, for example if you want to repeat the sound every second.
  • sin 960: any wave form or frequency will do. For a bell, sine makes most sense.
  • fade l: fade, logarithmic. I think that is the most 'natural' one for a bell.
  • 0: no fade-in.
  • 3 2.8: stay at full volume for 0.2 seconds, then fade out to silence during the remaining 2.8 seconds.

To make the bell toll multiple times, trim and repeat.

play -n synth 3 sin 960 fade l 0 3 2.8 trim 0 1 repeat 2

For a richer sound, play around with frequency modulation. For example, this already sounds a bit more like the sample alarm:

play -n synth 3 sin 960 synth 3 sin fmod 1920 fade l 0 3 2.8 trim 0 1 repeat 2