I am trying to demodulate a modulated FM Signal. As you can see in the code below I use fmmod to modulate the FM signal, however when I use fmdemod or ademodce then neither returns anything similar to the original signal. For fmdemod I believe it is that you can not enter freqdev as in fmmod, so it does not perform the reverse. With ademodce I have no idea why that is not working. Is there any other Octave function I can use to attain the original signal again or how do I use either one of these two correctly to do it?
See example code below:
[sound2,fs]=audioread('sound2.wav');
fc=7500;
freqdev=100;
dt=1/fs;
len=length(sound2)*dt;
t=0:dt:len;
t=t(1:end-1);
t1=t(1:end-1);
FMmod=fmmod(sound2.',fc,fs,freqdev);
FMDemod=ademodce(FMmod,fs,"fm",freqdev); %Or fmdemod(FMmod.',fc,fs) Neither is working.
sound(sound2,fs)
sound(FMDemod,fs)
subplot(2,2,1),plot(t,sound2),title('Original Sound');
subplot(2,2,2),plot(t,FMmod,'r'),title('FM Modulated');
subplot(2,2,3),plot(t,FMDemod,'g'),title('FM De-Modulated');
subplot(2,2,4),plot(t,FMmod-sound2.'), title('Carrier Signal');
Related
I am aware that I can use
let f = File::open("/dev/input/event0").unwrap();
let dummy = evdev_rs::UInputDevice::create_from_device(&Device::new_from_fd(f).unwrap()).unwrap();
But how would I create a dummy device that would be able to do all events(keyboard, mouse, etc) from no previous model? Also, I do not completely understand evdev, but if I were to receive an event from my keyboard and then write that exact event to the dummy would it work?
Edit: Sorry for the ambiguity, I realized that I actually want to create a UInputDevice able to produce events.
I've recently started Coding a program that will replace sound effects from a default directory, in the Source-Engine Game, Garry's Mod.
This is the current code:
function GM:PlayerFootstep( ply, pos, foot, sound, volume, rf )
ply:EmitSound("gear1")
return true
end
I want to emit multiple .wav Sound effects, without them overlapping, and being selected at random.
I have not found any Source helpful enough on the Internet to assist, so i resorted to Stack Overflow.
I would appreciate assistance with the topic.
You'll want to look at the file.Find function for this.
I'd recommend having a custom folder such as sound/customsteps/ where you can put all your custom sounds. I would also recommend using the .wav format for the sound files, but some others do work (.mp3 and .ogg if I recall correctly).
In your code, simply call local snds=file.Find( "sound/customsteps/*", "GAME" ) which gives you a table, then you can simply choose a random one from the list using local snd=snds[math.random(1,#snds)] and play it as you do in your above code - ply:EmitSound(snd).
Make sure you create the table of sounds outside of the GM:PlayerFootstep function, so that it only runs once. I would also recommend precaching all the sounds. You can do this by looping through the table and calling util.PrecacheSound(path) on them, like so:
for k,v in pairs(snds) do
util.PrecacheSound(v)
end
So, with all that in mind - your final code should look something like this:
local snds=file.Find( "sound/customsteps/*", "GAME" )
for k,v in pairs(snds) do
util.PrecacheSound(v)
end
function GM:PlayerFootstep( ply, pos, foot, sound, volume, rf )
ply:EmitSound(snds[math.random(1,#snds)])
return true
end
Source: personal experience
I need my [[+idx]] tv to start at 0 instead of 1 so I tried this:
[[+idx:decr]] or [[+idx:substract=1]] but it gives me -1 (minus one).
Does anyone know another way to obtain 0?
Thank you
Using this in chunk for getImageList works (at least for me):
[[+idx:decr]]
It gives: 0,1,2,3 ....
P.S. using modx revo 2.3.1
set your template variable default to 0 when you create the variable.
What are you trying to do, your question is vague at best.
UPDATE
ok - what I think will work for you is to write a snippet to do the math... where ever you call the [[+idx]] instead write a snippet
[[!FixIDX? &itemindex=`[[+idx]]`]]
then in your FixIDX snippet just do the math with php and return the corrected index. Though perhaps a custom output modifier would be the better way to go: http://rtfm.modx.com/display/revolution20/Input+and+Output+Filters+(Output+Modifiers)
Though looking at the docs, your code should certainly work - I see no reason for it not to.
On writing to the display with:
::TextOutW( pDC->m_hDC, x, y, &Out, 1 );
It only shows on the screen after every 15 calls (15 characters).
For debugging purposes only, I would like to see the new character on the display after each call. I have tried ::flushall() and a few other things but no change.
TIA
GDI function calls are accumulated and called in batches for performance reasons.
You can call GdiFlush after the TextOut call to perform the drawing immediately. Alternatively, call GdiSetBatchLimit(1) before outputting the text to disable batching completely.
::flushall() is for iostreams, so it won't affect Windows screen output at all. I've never tried it, but based on the docs, I believe GDIFlush() might be what you want. You should also be able to use GDISetBatchLimit(1); to force each call to run immediately upon being called.
can you suggest a good option for background subtraction using emgucv? my project is real time pedestrian detection.
Not sure if you still need this, but...in EmguCV, if you have 2 images of say type Image<Bgr, Byte> or any other type, called img1 and img2, doing img1 - img2 does work! There is a function called AbsDiff as well, I think it works like this: img1.AbsDiff(img2), you could look into that.
If you already have the picture of the background (img1) and you have the current frame (img2), you could do the above.
This is quite possible take a look at the "MotionDetection" example provided with EMGU this should get you started.
Effectively the code that removes the foreground is effectively named "_forgroundDetector" it is the "_motionHistory" that presents stores what movement has occurred.
The example has everything you need if you have trouble running it let me know,
Cheer
Chris
See:Removing background from _capture.QueryFrame()