LogoLogo
  • DSP4.3 - Real-Time DSP
  • Bill of materials
  • The Microcontroller
    • The ST Nucleo
    • STM32 Cube IDE
      • Useful tips
    • A simple test project
  • The Audio Peripherals
    • The Adafruit Boards
    • Real-time audio I/O
    • The digital microphone
    • The stereo DAC
    • The audio passthrough project
      • Setting up the I/O
      • Connecting the peripherals
      • Coding the passthrough
  • Real-World DSP
    • Numerical precision
    • Code efficiency
    • Signal levels
    • Benchmarking
    • Low Level Debugging
  • Voice Transformers
    • Introduction
    • Alien Voice
      • Basic implementation
      • The ON/OFF button
    • Granular Synthesis
      • The Formulas
      • Implementation
      • Last Details
    • About
Powered by GitBook
On this page

Was this helpful?

Export as PDF
  1. Voice Transformers

Alien Voice

PreviousIntroductionNextBasic implementation

Last updated 5 years ago

Was this helpful?

In this section we will implement the "alien voice" effect on the microcontroller. As shown in the , the alien voice effect is achieved simply by performing sinusoidal modulation on the input signal in order to shift the voice spectrum up in frequency.

Given a modulation frequency fcf_{c}fc​ (in Hz) and an input sample x[n]x[n]x[n] we can compute each output sample y[n]y[n]y[n] instantaneously as:

y[n]=x[n] cos⁡(2πfcFsn)=x[n] cos⁡(ωcn),y[n] = x[n] \, \cos\left(2\pi \frac{f_{c}}{F_s} n \right) = x[n] \, \cos(\omega_c n),y[n]=x[n]cos(2πFs​fc​​n)=x[n]cos(ωc​n),

where FsF_sFs​ is the system's sampling frequency (in Hz). The modulation frequency must be kept small in order to preserve intelligibility; still, the resulting signal will be affected by aliasing and other artifacts that we cannot really control.

As mentioned in the Jupyter notebook, this voice transformer is great for real-time applications as it requires only a single multiplication per sample. This means that, compared to the passthrough project, we will not have to write too much new code. But the devil, as they say, is in the details!

        .     .       .  .   . .   .   . .    +  .
          .     .  :     .    .. :. .___---------___.
               .  .   .    .  :.:. _".^ .^ ^.  '.. :"-_. .
            .  :       .  .  .:../:            . .^  :.:\.
                .   . :: +. :.:/: .   .    .        . . .:\
         .  :    .     . _ :::/:               .  ^ .  . .:\
          .. . .   . - : :.:./.                        .  .:\
          .      .     . :..|:                    .  .  ^. .:|
            .       . : : ..||        .                . . !:|
          .     . . . ::. ::\(                           . :)/
         .   .     : . : .:.|. ######              .#######::|
          :.. .  :-  : .:  ::|.#######           ..########:|
         .  .  .  ..  .  .. :\ ########          :######## :/
          .        .+ :: : -.:\ ########       . ########.:/
            .  .+   . . . . :.:\. #######       #######..:/
              :: . . . . ::.:..:.\           .   .   ..:/
           .   .   .  .. :  -::::.\.       | |     . .:/
              .  :  .  .  .-:.":.::.\             ..:/
         .      -.   . . . .: .:::.:.\.           .:/
        .   .   .  :      : ....::_:..:\   ___.  :/
           .   .  .   .:. .. .  .: :.:.:\       :/
             +   .   .   : . ::. :.:. .:.|\  .:/|
             .         +   .  .  ...:: ..|  --.:|
        .      . . .   .  .  . ... :..:.."(  ..)"
         .   .       .      :  .   .: ::/  .  .::\

.

Source
Jupyter notebook