How to produce sound

Coding and general discussion relating to the compiler

Moderators: David Barker, Jerry Messina

Post Reply
yllis
Posts: 10
Joined: Wed Feb 23, 2011 10:18 am
Location: Finland

How to produce sound

Post by yllis » Wed Mar 02, 2011 2:33 pm

I'd like to add a tune to my project. For some reason I can't find how to do this.
And I don't want a really complex system like in the SDMMCWavPlayer-example.

I'm trying to find a simple way to create a tune.
I assume it is possible to write a frequency and duration for every note? What would the code look like?

And a second question:
Is it possible to convert a sound to some format and just load it in to the pic? I saw something like this done in this page:
http://www.romanblack.com/picsound.htm
Would this work? And if yes, then how?

Thank you already in advance.

normnet
Posts: 55
Joined: Mon Jan 01, 2007 6:32 pm

Re: How to produce sound

Post by normnet » Thu Mar 03, 2011 4:01 am

[quote="yllis"...Is it possible to convert a sound to some format and just load it in to the pic? I saw something like this done in this page:
http://www.romanblack.com/picsound.htm
Would this work? And if yes, then how?

Thank you already in advance.[/quote]

The quality is poor.

Norm

yllis
Posts: 10
Joined: Wed Feb 23, 2011 10:18 am
Location: Finland

Post by yllis » Thu Mar 03, 2011 7:11 am

So then how do you make a pic give out sound?

but thanks for the comment Norm..

User avatar
Senacharim
Posts: 139
Joined: Tue Aug 10, 2010 5:19 pm
Location: Ventura, CA

Post by Senacharim » Thu Mar 03, 2011 2:46 pm

Given the limitations of an 8bit PIC so far as queuing and raw processing power, getting good quality sound will be difficult.

For just any sound, connect a PWM pin of the PIC to a speaker and you should be able to produce tones. (I've not yet tried this myself, but it's on my eventual 'to do' list.)
Surviving Member
Bermuda Triangle Battalion
from 2026 to 1992

Voted "Most likely to time travel"--Class of 2024.

normnet
Posts: 55
Joined: Mon Jan 01, 2007 6:32 pm

Re: How to produce sound

Post by normnet » Fri Mar 04, 2011 3:17 am

yllis wrote:I'd like to add a tune to my project. For some reason I can't find how to do this.
And I don't want a really complex system like in the SDMMCWavPlayer-example.

I'm trying to find a simple way to create a tune.
I assume it is possible to write a frequency and duration for every note? What would the code look like?

Thank you already in advance.
I believe you will need a SD wav player if more than a second or two of recorded sound.
Steve's SDMMCWavPlayer is good or to do a port of code based on Steve's earlier work see PIC iPod wav player.

Norm

Post Reply