Go Down

Topic: Playing sound from the computer. (Read 3 times) previous topic - next topic

Hampy

I know this is a hellishly simple feat to accomplish which is why I am so astounded and frustrated to not be able to find anything but tutorials and walls after walls of code for playing sound from the arduino. I have used processing before however am having trouble using the syntax associated with the arduino. I tried copying the method of playing sound from the processing environment however just run into heaps of errors such as:
exp:0: error: 'import' does not name a type
exp:1: error: 'Minim' does not name a type
exp:2: error: 'AudioPlayer' does not name a type

I've tried looking through the arduino reference to no avail. I did find one topic on the forum that was related however they ended up using an external program to execute the sound files which just seems rather convoluted as processing is able to execute it without any 3rd party help (correct me if im wrong). Help would be greatly appreciated.

Coding Badly

#1
Oct 05, 2010, 08:43 am Last Edit: Oct 06, 2010, 08:30 am by bcook Reason: 1

tone( FrequencyInHertz, DurationInMilliseconds );

Hampy

What? Isn't that used for generating simple tones? I want to play .wav files from my computer using sensors off the arduino to trigger them.

Groove

#3
Oct 05, 2010, 09:11 am Last Edit: Oct 05, 2010, 10:06 am by GrooveFlotilla Reason: 1
Quote
I want to play .wav files from my computer

Quote
exp:0: error: 'import' does not name a type

Sounds to me like you're confusing Processing (Java running on the PC with a soundcard) with Wiring (C/C++ running on the Arduino, with very little by the way of sound output hardware)
Per Arduino ad Astra

Coding Badly

Quote
Isn't that used for generating simple tones?

It is.

Quote
I want to play .wav files from my computer using sensors off the arduino to trigger them.

In that case, someone else will have to help.

Hampy

Quote
Sounds to me like you're confusing Processing (Java running on the PC with a soundcard) with Wiring (C/C++ running on the Arduino, with very little by the way of sound output hardware)


Alright? I'm not particularly sure what wiring is (unless you're referring to the programming platform which you use to program it which i know only as 'arduino alpha') but its my understanding that the platform was based on processing, and thus should have a similar set of commands. I havent read that what im trying to achieve is impossible, and judging from how it was implemented in processing I thought it could be achieved in a similar vein. The only thing I want from the arduino is the information it gathers from the light sensor I have attached to it. All the sound will be handled by the computer (just like processing) the only thing the light sensor/arduino is doing is acting like a switch. Thus I find it hard to believe that there is not a decently simple in-house solution to this... once again, there are people that know better than me so feel free to say otherwise.

PaulS

If you want your computer to play .wav files, when the Arduino reads some sensor value, then, you need to send the computer a message telling it to do so, using the Serial.print() function.

Then, you need to have an application on the PC listening to the serial port that can understand the message sent, and can play a .wav file.

As you have no doubt seen, Processing can play .wav files. It can also listen to the serial port. There are several examples provided with Processing that show how to do this.

So, the Arduino reads a switch, and sends a message "Hey, stupid! Queue up RidersOfThePurpleSage.wav" (or something like that), and Processing gets the message and plays the music.

Coding Badly


Actually, I may be able to help.  I believe this will accept a command from an Arduino to open a file on the host computer (e.g. play a WAV)...
http://www.mikmo.dk/gobetwino.html

AWOL

#8
Oct 05, 2010, 11:43 am Last Edit: Oct 05, 2010, 12:11 pm by AWOL Reason: 1
This sentence:
Quote
I have used processing before however am having trouble using the syntax associated with the arduino.

leads me to suspect that you are confusing the languages and the IDE.
C syntax is not the same as Java syntax.

Processing, which is based on Java, has nothing to do with Wiring, which is based on C and C++.

The Arduino is "inspired" by Processing, but compiling Processing code in the Arduino IDE will produce the sort of errors you reported.

Quote
but its my understanding that the platform was based on processing

No, the IDE is.
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Go Up