How to perform OOK modulation on Audio signal?

11 次查看(过去 30 天)
I have to convert my Audio signal in to discrete form and have to perform OOK modulation on it.

回答(1 个)

Walter Roberson
Walter Roberson 2018-6-21
  6 个评论
Asra Khalid
Asra Khalid 2018-6-26
编辑:Walter Roberson 2018-6-26
sigbin = reshape( (dec2bin(signal(:,1), 8) - '0').', 1, []);
byte = sum(group_of_8 .* 2.^(7:-1:0))
Can you explain these two commands? How did you choose these values?
Walter Roberson
Walter Roberson 2018-6-26
signal(:,1) is the first channel of the input signal.
dec2bin(something, 8) converts the input to character-coded binary with a minimum of 8 bits. 8 is specified because it could happen that the range of input values took less than 8 bits and we need a constant output width for the rest to work.
Subtracting the character '0' from the dec2bin() result converts each '0' to 0 and '1' to 1, thereby converting from character-coded binary to numeric binary.
dec2bin creates output in which the bits for any one input are across the rows. We want to take that output and make a single row vector in which the bits for any one input are beside each other. We start by transposing so that the bits for one output go down the columns, so 8 rows by however many columns are needed. With that memory arrangement, we can now reshape to 1 row and as many columns are needed.
a7 a6 a5 a4 a3 a2 a1 a0
b7 b6 a5 b4 b3 b2 b1 b0
->
a7 b7
a6 b6
a5 b5
a4 b4
a3 b3
a2 b2
a1 b1
a0 b0
->
a7 a6 a5 a4 a3 a2 a1 a0 b7 b6 b5 b4 b3 b2 b1 b0
The reconstruction formula I gave takes a single group of 8 numeric bits like a7 a6 a5 a4 a3 a2 a1 a0 and constructs the numeric vector 2^(7:-1:0) which is 2^[7 6 5 4 3 2 1 0] which is [128 64 32 16 8 4 2 1] . It multiplies the a7 a6 a5 a4 a3 a2 a1 a0 by that, getting a7*128 a6*64 a5*32 a4*16 a3*8 a2*4 a1*2 a0*1 . Then it adds those getting a7*128+a6*64+a5*32+a4*16+a3*8+a2*4+ a1*2+a0*1 . Which is precisely the numeric integer reconstruction of the binary sequence a7 a6 a5 a4 a3 a2 a1 a0, by definition.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Multirate Signal Processing 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by