I am trying to create an application for polling different sensors. I want to make this polling efficient so that I don't poll a slow changing sensor very frequently. On the other hand there may be some sensors like temp sensor whose values keep on changing frequently.
I found an analogy in twitter. When a twitter stream is open how does it automatically give real time notifications of new tweets? . They must be polling a web server of tweet. Right? How this polling rate is decided. There must be some algorithms or may be I am missing proper term/keyword for this thing to Google it. This must have got something to do with push and pull based architectures. Right?
For getting accurate sensor waveforms, search for Nyquist rate, e.g., this Wikipedia page
If you are going to be filtering your sensor streams, it is best to sample at a fixed frequency to make the filter math easier.
Related
I am working on a smartwatch project. I want the display to be turned off and only come on when the user brings his hand into the watch-viewing position.
I am running my application on the NRF52 MCU which means machine learning is out of the question. I am using a 3-axis accelerometer from STM.
How can I detect when a user moves his hand into the typically watch viewing position? How is this achieved in smartwatches?
I have the following ideas so far:
- Constantly poll accelerometer and calculate pitch and roll values. Then determine what range of pitch and roll values corresponds to this gesture. This seems a bit wasteful because the CPU will have to be always active.
Is there a simple signal processing algorithm or something similar that can achieve this?
Look into Galvanic skin response sensor - It can measure electrical connectivity of the skin.
When internal or external forces cause arousal — of any kind — the skin becomes a better conductor of electricity. Essentially, when you start to sweat, either from exercise or something else, the band will be able to monitor that.
Detecting when someone is sweating gives the software more information about what a user is doing, which allows for better health tracking. Being able to correlate the level of activity with a different source than just gravity from the accelerometer, allows these programs to take on a more trainer-like role — recommending specific exercises and levels of exertion.
Hope this helps!
I would like to capture road traffic data for a specific location and in a specific period and then I require to do some analysis on data. I try to check how I can do that. I found that I am able to use some public API for obtaining traffic information but I feel there could be other way as well. I require this data for a Big Data project.
Please suggest me how I should store data as well, I mean what is the best practice for store a big range of data of traffic.
Well, your question is very general! As I understand and based on my experience,
I suggest you something:
1- First and most efficient is that you can analysis your data online then extract your statistics and keep your results.
Easy for research here: http://www.mathworks.com/help/images/examples/detecting-cars-in-a-video-of-traffic.html
2- You can tag your data and keep only the sequences that you need, at least ignore a big unnecessary data automatically.
3- If you need to keep the video sequences for any reasons, then I suggest to use video compressors and decrease your videos not only by compressors also in terms of size.
http://video-compressor.en.softonic.com/
I want to change the frequency of a voice recording by changing sample rate on Mac OS X.
This is a research project aimed at people who stutter. It's essential that the latency is very low – this is, for instance, why I'm not considering Fast Fourier Transforms. Instead, I want to collect samples at a rate of, say, 44kHz, then do one of two things:
1) Play the samples back twice as slowly (i.e. 22kHz). This will result in increasing asynchrony with the source. It would be useful if I can restart the sampling every 1 second or so to prevent the asynchrony from becoming too noticeable.
2) Play the samples back twice as quickly. Obviously, it's impossible to do this continuously (i.e. can't play back samples which haven't been collected yet). To get around this, I'm intending to gate the playback with a square wave. Samples will be played back twice as quickly as they were recorded during the peak of the square wave. Nothing will be heard (but samples will still be collected) during the trough of the square wave.
I've prepared a PDF which describes the project in more detail here:
https://www.dropbox.com/s/8u3tz7d9hhxd3t9/Frequency%20shift%20techniques.pdf?dl=0
A friend has helped me with some of the programming for this using PortAudio. Unfortunately, we're getting very long latencies. I think this might be because PortAudio is working at too high a level. From the code, it looks to me as if PortAudio is buffering the incoming audio stream and then making alterations which are prima facie similar to the ones I've described above, but which are in fact operations on the buffered stream.
This isn't what I want at all. It's essential that the processing unit does as little as possible. Referring to the conditions (1) and (2) above, all the computer should do is to (1) play back the samples without any manipulation but twice as slowly; or (2) store the incoming samples then play them back twice as quickly. There should be no other processing whatsoever. I think this is the only way I'll get the very low latencies I'm looking for.
I wondered if it would be better to try doing this directly in Core Audio for OS X, rather than using PortAudio? This would limit platform compatibility. But the low latency is much more important than compatibility.
Am I likely to be able to do what I want using a mid-level service, such as Audio Units? Or would I need to write directly for a low-level service such as I/O Kit? How would I go about it?
It looks like the best thing for you would be to use something like Max/MSP or Pure Data. This will allow you to avoid working with text-based languages and should be good for you rapidly develop what you're looking to do. I/O kit is a bit too low-level for what you're trying to do.
Since max is not a text based language, sharing the code itself is a bit tricky on sites like stack overflow. I've included a screengrab. You can copy and paste max code, but it's a bit ugly and innappropiate for this.
here's a quick description. The box that says rect~ 1 is generating a square wave at Hz. The snapshot~ box is capturing the values this spits out. The if boxes check when it's greater than zero or less than zeros (peaks and troughs). If it gets a trough, the record~ box records the signal from the microphone box and stores it in a buffer. the groove~ box is a sampler that plays back the audio in this buffer, when it recives a bang from the if box, it plays back the audio. The sig~ box is being used to control the playback rate.
Also, you may not know this but the .PDF you're trying to share is unavailable.
One other thing, if latency is important, you should learn about something called a click train. This is basically where you send a signal with a single 1 at the start and time how long it takes for that value to get through your system.
i need a bpm counter witch send a message if a tempo of incoming Audiosignal changes. Have anyone an idee?
It sounds like you're really new to Max MSP and audio processing in general so I really can't stress the importance of understanding how audio processing works in general and how much you'll learn just going through all the built in tutorials in Max. Beat detection is a pretty complex thing though, take a look at how even pro softwares like Ableton and Traktor have trouble tracking beats sometimes, and they have people who've worked on their algorithms for years.
There are a number of ways you can do an implementation in Max, it really depends how much time you want to spend and how complex you want to make it. The simplest would be to put a low pass filter on your track (if you're measuring against the kick drum), and then get the level of the signal, then set a numeric threshold that triggers when the level goes over a certain value, and have that connected to a bang that is connected to a tap tempo calculation. You can find an example of a tap tempo at this link: https://cycling74.com/forums/topic/tap-tempo-2/
Another option is to use the beat~ object found here: http://web.media.mit.edu/~tristan/maxmsp.html
For the message sending side of things, who are you sending a message to? You can use udpsend to send messages over the network, you can send midi out values, or just use the built in send and receive objects if you're just sending data around in Max.
I am developing a simple fast-paced 2 dimensional real-time multiplayer game in Flash. Players can only shoot and walk in point to move fashion. I use TCP socket connection (AS3 doesnt offer UDP).
All I want is to synchronize players' actions so Player1 could see the same on its screen as Player2,Player3... or just see close representation (position,taking damage,etc).
I know movement vector coordinates and I can easily interpolate on them using latency.
However, I can not figure out an effective way to determine how much time (T1) did it take the state update to travel client1-server-client2 and then make corrections to client2's screen based on T1. (You know, ping times may fluctuate quite a bit).I need a way to do the above-mentioned, i need way which is as fast and as accurate as posssible but not extremely sophisticated. (what algorithm should i use? what is the solution - timestamps, maybe or what? - I dont know.)
First of all, I think the server should constantly have updated information about the entire "world". All the clients send their playing actions (that is, what the player does, like movements, shootings, etc) to the server, and using compressed data.
I would divide the "world" into regions. Each player has of course a limited view, so he can't see all the world at once (luckily), thus he needs to get updates to only the regions he can see.
So the thing is:
The server generates the world, and divides it into regions.
When a player enters the world, it gets general information about the entire world and detailed information about the regions in his sight
Each action of a player that has consequences, must be sent to the server (compressed) that acquires the information. If the status change has the effect of changing one or more regions, each user interested in those regions must receive the change notification
It looks like a publish/subscribe design pattern (Observer), but
each client is the publisher and the server is the subscriber for what concerns the player status change.
the server is publisher and the clients are subscribers for what concerns the world change, but only for the regions each player is interested in. this is a particular Observer in that the subscription changes over time (regions) due to movement