NAudio - How to Record from left or right channel only? - record

I need to record simultaneously from two sources, one connect to the left channel of my mic, the other connect to right. Possible to do that with NAudio ?

Yes, but you will be recording from both channels at once, so the samples will arrive interleaved. Assuming you are recording in 16 bit audio, you would take two pairs of two bytes from the recorded buffer, and write one pair to one WAV file, and one to another.
See my answer here showing how you do this for an existing multi-channel WAV file.

Related

Reverse read of multiple Redis Streams (imaginary XREVREAD command)

With redis streams I can read multiple streams in a chronologically forward direction.
Each stream is read from a point in time up to to newest point in that stream.
I can get the oldest item multiple streams
XREAD COUNT 1 STREAMS streamA streamB streamC 0-0 0-0 0-0
and from there (noting the returned id's) move forward consuming all the items in a selection of streams. Limiting consumption to only 1 item per stream.
How can I easily consume multiple streams in reverse. Starting with the newest items on the tip on a stream and stepping backwards in time, whilst constraining consumption to only 1 item from each stream?
You can't, since Redis doesn't supply this XREVREAD command as of version 6.0.
The closest is XREVRANGE except it only takes one stream at a time. If you really want to, you might have to write a lua script so you can provide multiple streams, have the script loop the streams and call the XREVRANGE command, then result the results at once.

joining Redis streams

I am very intrigued by Redis streams. (Looks like the potential to build little systems powered by append-logs, like Kafka, but without all the overhead of Kafka.)
It looks straightforward to XADD to a log/stream and to consume an entry from a log/stream. But what about if you want to join across two streams?
Kafka Streams, Flink, Spark, etc. provide means for doing this. Is there an equivalent in the Redis universe?
If not, I guess I'll just need to implement my own thing that consumes from two streams, does its own join logic from the messages, and publishes back out to a new stream. If others have experience doing this with Redis Streams, please do share your pointers or warnings.
If I am correct, you are looking for a way to join two Redis streams.
It seems there is a connector available for Spark, that allows you to consume the streams https://github.com/RedisLabs/spark-redis/blob/master/doc/streaming.md
From here Spark logic for the join should be easy to use.
I have attended the Redis University Stream course and they does not show any built in method to join messages from two streams.
I guess one work-around would be to handle the IDs in a proper way.
Let's make an example:
You produce messages to stream A with even IDs.
You prodce messages to stream B with odd IDs.
You consume from stream A and stream B and produce to a new stream C being careful on respecting the order because it is not allowed to produce an ID equal or smaller than the larger already present in the stream.
In this whay you achieve the join.
Looking forward to better answer not using external libraries

GPS coordinates not updated every time

I'm using SIM808 to get GPS coordinates. I'm fetching GPS data every 10 seconds. But I'm getting the same GPS coordinate 2-3 times. AT command (CGPSINF) does not yield a new coordinate on every call, so I get repeatedly the same coordinate.
Please help me out why I'm not getting updated GPS coordinate on every AT command call. Previously I was working on Ublox GPS receiver, same things happened there. That module also sent repeated coordinates when I was using this with a Python library on Raspberry Pi.
There will be some data stored in buffer in serial. You have to flush it before you read the data.
Suppose your serial port is defined like this:
ab= serial.Serial('/dev/ttyUSB0')
So before reading data flush the buffer.
ab.flush()
Then read the data from it.
ab.readline()

To receive the data from two remote XBees in LabVIEW without getting mixed?

I have two remote XBees each is connected to a microcontroller. The microcontrollers sample the waveforms of two different points of power system and send data to receiver xbee which ultimately is imported into LabVIEW.
Now the problem is I need to analyze the two different data streams without for example a data point from XBee 1 ending up in the XBee 2 data set.
One method that I think is to introduce some recognized numbers in sending data so that on its basis we can identity that the data is of Xbee 1 or 2. How can I do that?
http://forums.ni.com/ni/attachments/ni/170/964005/1/ThreePhaseNewwindow.vi
http://forums.ni.com/ni/attachments/ni/170/964005/2/Capture.PNG

Data Optimization in GPS Tracking

I'm building a real-time GPS tracking system. The mobile client continuously sends location data to server and updates the location data of tracking objects every 15 seconds.
My biggest problem is that the cost of battery and internet is very high.
Is there any solution thats help optimizing data transfer between client and server ?
You know that you have a good solution when you reach
2-3 bytes per GPS position with 4-5 attributes (time, lat, lon, optionally speed, heading)
Try to avoid security, this destroys all attempts to reduce data size. The ammount of bytes that the security (signatures, headers, keys) uses is far more than that of the GPS Data packet.
Is there any solution thats help optimizing data transfer between
client and server ?
Yes, at least some tipps: Do not use XML, that blows up your data by a fatcor of 100 to 1000. Use a binary protocol. A WSDL Web Service ar not well suited for this task, too.
The less frequent the device need to communicate the better the chances to get more fixes per kbytes.
An uncompressed position: needs 12 bytes: time (4), latitude (4), longitude (4).
Different companies have differnt solution to compress the data. I know one patented solution, and one confident. More I cannot tell you.
Battery
If you disable the screen, you can record 8 hours of one per second positions on an iphone4.