0

I have sound clips that are about 3-4 seconds in human audible range. I want to convert them into ultrasonic range so that when I transmit them they are not audible to humans. I read that I need to use amplitude modulation. I used the modulate function of matlab.

[y,Fs] = audioread('TakeASelfie.mp3');
x = modulate(y,30700, 62000, 'amdsb-tc');
soundsc(x,62000)
audiowrite('modulated.wav', x, 62000)

In the above example, I was trying to convert my audio clip to 30.7kHz. However, after I performed modulation, the length of the clip was decreased. How can I change the frequency of my sound clip without changing the length of it? I am also not sure if the approach I am taking is the right one.

krish
  • 63
  • 8

1 Answers1

1

One way to do it (this method will give you lowwer sideband, for example if your audio signal have spectra from 200 to 2000 Hz and carrier frequency f0 = 40000 Hz, your ultrasound signal will have spectra from 39800 to 38000 Yz):

fs=96000; % samplig frequency (should be at least x2.2 of f0 )

[sb, fd]=wavread('as4.wav'); % signal in audio domain
if fd ~= fs                  % change sampling prequency to target
    sb = resample(sb, fs, fd);
end    
sb=sb./max(sb); % normalization

A = 1; % amplitude of carrier tone 
T = length(sb) / fs; % length of signal
f0 = 40000; % carrier frequency
Fi0 = pi/2; % initial phase
N = T * fs;  % number of samples
t = (0 : N-1) / fs;  % time stamps

sa = A * sin(2 * pi * f0 * t + Fi0); % samples of carrier tone

% first method
s = sb .* sa + imag(hilbert(sb)) .* imag(hilbert(sa));
% to have upper sideband use
% s = sb .* sa - imag(hilbert(sb)) .* imag(hilbert(sa));

% second method
s = ssbmod(sb, f0, fs);

s=s./(max(s)); % normalization of modulated signal