Pages: [1]   Go Down
Author Topic: Playing sound from the computer.  (Read 2327 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 3
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Global Moderator
Dallas
Offline Offline
Shannon Member
*****
Karma: 176
Posts: 12283
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset


tone( FrequencyInHertz, DurationInMilliseconds );
« Last Edit: October 06, 2010, 01:30:23 am by bcook » Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 3
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

UK
Offline Offline
Faraday Member
**
Karma: 16
Posts: 2883
Gorm deficient
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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)
« Last Edit: October 05, 2010, 03:06:38 am by GrooveFlotilla » Logged

Per Arduino ad Astra

Global Moderator
Dallas
Offline Offline
Shannon Member
*****
Karma: 176
Posts: 12283
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 3
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Seattle, WA USA
Online Online
Brattain Member
*****
Karma: 548
Posts: 46032
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Global Moderator
Dallas
Offline Offline
Shannon Member
*****
Karma: 176
Posts: 12283
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset


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
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 238
Posts: 24322
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
« Last Edit: October 05, 2010, 05:11:17 am by AWOL » Logged

"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.

Pages: [1]   Go Up
Jump to: