DZone
Web Dev Zone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
  • Refcardz
  • Trend Reports
  • Webinars
  • Zones
  • |
    • Agile
    • AI
    • Big Data
    • Cloud
    • Database
    • DevOps
    • Integration
    • IoT
    • Java
    • Microservices
    • Open Source
    • Performance
    • Security
    • Web Dev
DZone > Web Dev Zone > Police Sirens and Frequency Modulation

Police Sirens and Frequency Modulation

Ah, the allure of the police siren call! Have you ever wondered how they sing their magical song?

John Cook user avatar by
John Cook
·
Mar. 18, 16 · Web Dev Zone · Tutorial
Like (1)
Save
Tweet
3.81K Views

Join the DZone community and get the full member experience.

Join For Free

yesterday, i was looking into calculating fluctuation strength and playing around with some examples. along the way, i discovered how to create files that sound like police sirens. these are sounds with high fluctuation strength.

police car lights

the python code below starts with a carrier wave at f c = 1500 hz. not surprisingly, this frequency is near where hearing is most sensitive. then this signal is modulated with a signal with frequency f m . this frequency determines the frequency of the fluctuations.

the slower example produced by the code below sounds like a police siren. the faster example makes me think more of an ambulance or fire truck. next time i hear an emergency vehicle, i’ll pay more attention.

if you use a larger value of the modulation index β and a smaller value of the modulation frequency f m , you can make a sound like someone tuning a radio, which is no coincidence.

here are the output audio files in .wav format: slow.wav , fast.wav

from scipy.io.wavfile import write
from numpy import arange, pi, sin

def f(t, f_c, f_m, beta):
    # t    = time
    # f_c  = carrier frequency
    # f_m  = modulation frequency
    # beta = modulation index
    return sin(2*pi*f_c*t - beta*sin(2*f_m*pi*t))

def to_integer(signal):
    # take samples in [-1, 1] and scale to 16-bit integers,
    # values between -2^15 and 2^15 - 1.
    return int16(data*(2**15 - 1))

n = 48000 # samples per second
x = arange(3*n) # three seconds of audio

data = f(x/n, 1500, 2, 100)
write("slow.wav", n, to_integer(data))

data = f(x/n, 1500, 8, 100)
write("fast.wav", n, to_integer(data))

related posts

  • analyzing an fm signal
  • energy in fm signals
Signal Python (language) POST (HTTP)

Published at DZone with permission of John Cook. See the original article here.

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • DZone's Article Submission Guidelines
  • Datafaker: An Alternative to Using Production Data
  • Troubleshooting Memory Leaks With Heap Profilers
  • Composable Architecture

Comments

Web Dev Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • MVB Program
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends:

DZone.com is powered by 

AnswerHub logo