Java or C++: Send current to USB when sound plays - java

Is there a way in java, or even C++, to send current depending on how much sound is playing?
Let's say, if there is a lot of sound playing, the USB port will be receiving 20mA, and if there is very little sound, the USB port will receive 5mA, and if there is no sound, obviously 0 current / voltage. You don't have to go too in depth with your response. Just maybe point me in the right direction and help me get started.
I do prefer java over C++, that would be great.
Thanks!

This in the proposed form is not doable. The power supply is either turned on, or off, but not in between. without hardware you can not make a LED sound meter out of it...
However, it would be fairly easy to accomplish this using commercially available, USB ready building blocks. There are multiple options, but I'd prefer an Arduino. Connected to the USB port, it can be connected as if it was a serial port, and that is nőt very difficult to do. For this, you need these to be done:
get an Arduino
write a sketch in C that accepts your input, lets say ASCII encoded decimal integer values, and does the function you want, like power a LED through PWM pin with variable duty cycle (Arduino side)
write your code, that acquires whatever you need ("how much sound is splayed", whhatever that means...), on the PC side, in whatever language you prefer
send the numeric values to the Arduino using serial port communication from the PC side code

No. The hardware does not support this functionality. The USB port is not a DAC.

i think both are good, unless you know the concept the language u going into.
but still, i'll prefer java beacuse of simple coding.
you can use sequencer or mixer and can send it to the port you want.
mixer can handle sending/reciving multiple midi events.
but in java , sound API is not much advance, but in c++ u can use
python's large liabrary,which can help you to get the frequency
or voltage.where as in java,functions are limited,
and at time's you need to add external liabrary or preform
FFt(i hate this part).
that's it! good luck

Related

Advice on ultrasonic transmission protocol

I am working on an application that will receive ultrasonic waves and it will perform different actions based on the input. At some point, I am going to need that this ultrasonic waves to be unique for my application in the sense that I don't want other waves to interfere. Can you please give me some guidance on the protocols for making a wave sound "unique"? There are commercials applications for that like cue audio. I am planning to write the application using Android. Thanks in advance.
"Direct sequence spread spectrum" (DSSS) transmission is used to make communication resistant to jamming and interference, which seems to cover your use case as well.
It's reasonably easy to implement digitally. See: https://en.wikipedia.org/wiki/Direct-sequence_spread_spectrum
This might be more of a dsp question, but you could use frequency shift keying, where you encode a pattern as a series of frequencies and then recover them: https://www.tutorialspoint.com/digital_communication/digital_communication_frequency_shift_keying.htm
If its for rangefinding, have a look at chirp signals used in radar: http://www.dspguide.com/ch11/6.htm Not exactly what you asked I know but probably of interest as well. These are commonly used in radar systems.

Is there a class for Arduino in C++ that is similar to the Minim class in Processing?

I want to be able to take in a file for music, analyze it and then make lights light up to the music. The only problem is, with the board that I built, using Processing has a big delay on the code that runs and it has maybe a obvious 10 ms gap. I need a way to either bring the program back into Arduino, or somehow lower the response time. Any ideas?
It's unclear how you're dealing with the serial communication and where the bottlenecks would start to show up (audio processing/serial comms/both/something else/etc).
Regardless, if you want to do sound analysis on Arduino alone, that will be a challenge, as you'll have a lot less resources to do the FFT number crunching on an 8-bit micro controller.
I would go either of two ways:
Do the sound analysis as efficient as possible on the computer and map it to lights so the software(Processing) only sends minimal data to the firmware(Arduino)(just light data, on a need to know basis). If you have a ridiculous amount of lights you might want to use a serial converter than can handle higher baud rates, but in most cases you shouldn't need that.
Do a minimal sounds analysis on Arduino. If you got your light animations right, you can make something sound reactive using just the amplitude and a bit of easing without getting into FFT/MFC or anything fancier. If you really really want light responsiveness to frequencies consider using a 7 band frequency analyser chip like MSGEQ7. There are Arduino breakouts that make that easier.

Possible to modify mini controller/micro controller code on store product?

My girlfriend recently bought a product for her skin, its basically a mask with lights on the inside that runs a power cord similar to an auxiliary cord into an auxiliary port on a mini controller. It is only good for 30 uses, every time you turn it on, an lcd screen counts down til it hits 0, then you have to buy a new controller.
I find it extremely wasteful to buy a new plastic controller after 30 uses. My question is it possible to somehow connect this device to my laptop through the aux port or aux port extension and modify the code written on it.
I work as a web developer by trade, so I am no stranger to code. I just need to know how to connect it, read the code and compile the code, etc, to modify the counter or remove it.
It is ЯU 94v-0 mini controller (Yes, the R is backwards)
Interestingly enough if I plug the mask into my iPhone or Mac, it will power one set of lights (there are two types/sets), but not the other.
Thanks in advance for the hackery advice.
I Have Better IDEA! Just buy new device (This device has an memory ATMLH436, which is basically same as AT24C02 eeprom chip), disconnect the WP pin and connect it only with the VCC pin, it then can't write the counter down (since it will be write protected), every time you pull the batteries out and in again, it will be as fresh as new. Should work like a charm :D
Here is the historical answer, maybe usefull to someone in the future:
How to hack instruction.
This device has an memory ATMLH436, which is basically same as AT24C02 eeprom chip, which is an EPROM with I2C interface, it is 2 KBytes memory. And the counter is most likely stored on this element.
You need to buy a new device, connect the not used eeprom to a i2c programator (you need to buy one, or ask a friend, I remeber this as a simple device connected to a rs232 port, but you can find one for usb), read the memory content and store it in a file and then you can use this file to reprogram the eprom to the original "new" state every time you want.
How to connect the i2c eeprom to mac:
hmmm, you need to have an i2c programator, that's first step.
Check the one you're about to buy if it has a Macintosh compatible software for reading/ writing.
If not, maybe use other computer.
remeber that in order to be able to program the device you need to connect the pin 7 (Write protect pin) to the ground. Here's the chip spec: http://www.atmel.com/Images/doc0180.pdf
Basically in oreder to communicate with the device you need:
know the address of the device - it is set by the A0,A1,and A2 pins connected either to ground or VCC - the programator soft will require that address.
connect the SDA, SCL and GND pins to the programator.
the chip need power supply of 5V connected beetween GND (-) and VCC (+) to operate.
In order to program the WP pin needs to be connected to GND.
There are big chances that: A0,A1,A2 and WP are grounded, but I can't be sure.
In case of this scenario the address of the device is 1010000 and there's nothing left that needs to be done in oreder to program it. I assume if the WP pin is not grounded you can disconnect it from whatever it is connected to and hardwire it to ground - should not affect normal operation of the device. probably you don't need to unsolder the chip in order to be able to read/write it, you need to connect GND, SDA, SCL and VCC. I would make a connector for these 4 pins to have it accessible from ouside of the device.
In order to make my life easier for many reprogram cycles, I would solder some connector to not have to disssassemble the device each time I need to reprogram it.
There are small chances that the counter is in the fat black round dot on the PCB, in which case there's nothing you can do to reset it since it is some custom chip without spec - if you have a great lab with X-RAY machine (like https://www.hawkerrichardson.com.au/electronic-production-systems/inspection-test-a-repair/unicomp-ax-8200) and other such stuff + lot of experience you could :) but rather not many people have such toys since they are very expensive :)
There are some pins to connect to the rounded chip, but I don't have any idea how to use them, what's the protocol or anything...
but if they could produce eprom inside of it, they wouldn't probably use any additional external eeprom because of the costs. But since eeprom production is not so easy as the regular chip, they use rather external memory from other supplier rather that producing one by themself - it's one logical argument that the counter is there in the AT24C02.
The correct way to hack this thing would be to listen to the I2C communication line with a scope. Note the exact binary sequence.
Then remove the external eeprom entirely and replace it with another MCU, which only has one task and that is to reply as the main MCU expects it to do. Though of course it never saves the down-counter.
Essentially you'd get this sequence each time you power up:
Main MCU: "Hello my eeprom, can I get the counter?"
Hack MCU: "Err yes I am totally an eeprom, the counter is 5."
Main MCU: "Store the counter value 6".
Hack MCU: "Roger that" (does nothing).
You'll get the same sequence over and over.
To succeed you need to know: microcontroller programming, I2C, basic electronics, soldering.

How do I get the Arduino Nano to communicate with a phone through Java?

My goal: Make my phone control an Arduino which controls servos which will do cool animations.
How do I get to my goal: I use Java to communicate to the Arduino Nano through the yellow pins (visible on the right picture) through serial (RxD/TxD) (RS-232 protocol) which will tell the Arduino how to control the servos or motors.
Problems:
I don't know which one of the pins that does what, like which one that is GND, which one that is TxD or RxD
I don't know how to tell the phone to do things with its yellow pins (which the Arduino will read and understand to control its servos/motors)
[_] I don't know how to listen to the phone's accelerometer through Java - The thing that lets it tell what is down
[_] I don't know how to listen to the phone's light-sensor
[_] I don't know how to listen to the phone's microphone
[_] I don't know how to listen to the phone's camera
[_] = Things I'm just very curious about that I will use for future projects.
Extra information: I got NetBeans IDE 7.1.1, and I got an Arduino Nano, I got the phone shown above which is called "J10i2 Elm Sony Ericsson".
So I guess what I'm really looking for is someone who knows how to control a phone 100% through Java. Or being pointed in the right direction is also nice!
If you think that I can do this in a better/simpler/smarter way then feel free to leave a comment stating why and how it is better ;)
I would suggest one easy solution, use a REST web service (SOA arquitechture) to solve this problem i did it in my personal case and now im able to control and monitor my house :)
You could simply create a database table representation of your arduino's pins...then just create a service that receives some parameters (i.e> pin no, status -> 1/0, arduino id, etc) and saves them in the database, with your mobile app you could just use the same web service for changing the values.
Finally write down an Arduino app that keeps reading statuses from that service and database (of course using another endpoint/ method in which case you just need to pass your arduino id and it will return a response of all of the different pin status so you can read/process them from your arduino (for example since JSON library is heavy and slow on arduino im passing my return values back from the server to the arduino using simple CSV values i.e> "[pin:status,.....]" i have some code for making HTTP/GET/POST on Arduino you just need the ethernet shield , i could bring you the code if you are interested

Audio programming, Sound Processing and DSP

I was playing with a karaoke application on iPhone and came up with following questions:
The application allowed its users to control the volume of the artist; even mute it. How is this possible?
Does adjusting artist sound/setting equalizer etc. mean performing some transformation of required frequencies? What sort of mathematics is required here(frequency domain transformations)?
The application recorded users voice input via a mic. Assuming that the sound is recorded in some format, the application was able to mix the recording with the karaoke track(with artists voice muted). How can this be done?
Did they play both the track and voice recording simultaneously? Or maybe they inserted additional frequency(channel?) in the original track, maybe replaced it?
What sort of DSP is involved here? Is this possible in Java, Objective C?
I am curious and if you have links to documents or books that can help me understand the mechanism here, please share.
Thanks.
I don't know that particular application, probably it has a voice track recorder separately.
For generic 2-channels stereo sound the easiest voice suppression can be performed assuming that artist's voice is somehow equally balanced between two channels (acoustically it appears in center). So the simplest 'DSP' would be subtract one channel from another. It does not work that well however with modern records since all instruments and voice are recorded separately and then mixed together (meaning that voice will not be necessarily in phase between two channels).
I have written two detailed blogposts on how to get a custom EQ in iOS. But i have no details about how to do the DSP yourself. If you simply want to choose between a wide range of effects and stuff, try this.
First post explains how you build libsox:
http://uberblo.gs/2011/04/iosiphoneos-equalizer-with-libsox-making-it-a-framework
The second explains how to use it:
http://uberblo.gs/2011/04/iosiphoneos-equalizer-with-libsox-doing-effects
please up the answer if it helped you! thanks!

Categories