|
|||||||
| Home | Forums | Rules | Articles | Store | Gallery | Blogs | Register | Donations | FAQ | Calendar | Search | Today's Posts | Mark Forums Read | Search |
| Digital Source Digital Players and Recorders: CD , SACD , Tape, Memory Card, etc. |
|
Please consider donating to help us continue to serve you.
Ads on/off / Custom Title / More PMs / More album space / Advanced printing & mass image saving |
|
![]() |
|
|
Thread Tools | Search this Thread |
|
|
#1 |
|
diyAudio Member
Join Date: Jan 2006
Location: New York
|
Hello-
I am running a bass heartbeat noise through a self-contained amplifier/subwoofer. The speed of the heartbeat sound is directly related to the person whom the heartbeat belongs to. I want to store "lub-dub" and play it back faster or slower. To me, this means that the lub-dub noise needs to play then instantly rewind, then play again. In addition, the output needs to be in the 2-5V range. I have been working with Birthday card type recordable sound cards, but the output is too quiet and quality is not good. The control system/electronics are an embedded board which I am designing. Does anyone have any recommendations or advice? Thanks! Nora |
|
|
|
#2 |
|
diyAudio Member
Join Date: Nov 2002
Location: Fort Wayne, IN
|
I've done what you want to do with an arduino an SD card and a simple I2C dac chip. My little code speaks the value of the analog input. I pre-recorded the sounds for the numbers 0-9 and ".", and then the program just sends them out one at a time. The only logic is selecting the correct file to spit based on each digit of the reading. What you want to do is similar, but you'd change the delay rather than which file is being sent.
The arduino is overkill for what you want to do. I bet you could do the whole thing with a pic micro including a PWM DAC output. Sheldon #include <AF_Wave.h> #include <avr/pgmspace.h> #include "util.h" #include "wave.h" #include <Stdio.h> AF_Wave card; File f; Wavefile wave; // only one! int valLen= 0; int digit = 0; int val = 0; int analogPin = 0; char cval[4]; void setup() { Serial.begin(9600); // set up Serial library at 9600 bps Serial.println("Analog Input speaker"); pinMode(2, OUTPUT); pinMode(3, OUTPUT); pinMode(4, OUTPUT); pinMode(5, OUTPUT); if (!card.init_card()) { putstring_nl("Card init. failed!"); return; } if (!card.open_partition()) { putstring_nl("No partition!"); return; } if (!card.open_filesys()) { putstring_nl("Couldn't open filesys"); return; } if (!card.open_rootdir()) { putstring_nl("Couldn't open dir"); return; } } void loop() { digit=0; val = analogRead(analogPin); Serial.print("Analog input: "); Serial.println(val); sprintf(cval,"%d",val); valLen=4; if (val<1000)valLen=3; if (val<100) valLen=2; if (val<10) valLen=1; while (digit<valLen) { char c = cval[digit++]; Serial.print(c); speaknum(c); delay(10); } delay(3000); } char filename[13]; void speaknum(char c) { uint8_t i=0; if (c <= '9' && c >= '0') { // single digit filename[0] = c; i = 1; } else if (c == '.') { filename[0] = 'P'; i = 1; } else { return; } if (i != 0) { filename[i] = '.'; filename[i+1] = 'W'; filename[i+2] = 'A'; filename[i+3] = 'V'; filename[i+4] = 0; playcomplete(filename); } } void playcomplete(char *name) { playfile(name); while (wave.isplaying); card.close_file(f); } void playfile(char *name) { if (wave.isplaying) {// already playing something, so stop it! wave.stop(); // stop it card.close_file(f); } f = card.open_file(name); if (!f) { putstring("Couldn't open file "); Serial.print(name); return; } if (!wave.create(f)) { putstring_nl("Not a valid WAV"); return; } // ok time to play! wave.play(); } |
|
|
|
#3 |
|
diyAudio Member
Join Date: Jan 2006
Location: New York
|
Thanks!!
So the SD card automatically rewinds? What do you use to hold the SD card? Clearly I'm clueless...so details are appreciated!! I'm going to use a PIC, there's a bunch of other stuff in this circuit and I'm not so used to Arduino. |
|
|
|
#4 |
|
diyAudio Member
Join Date: Nov 2002
Location: Fort Wayne, IN
|
Arduino is just a bootloader for one line of the atmega uC's. IT provides an easy means of noodling around with them. It's aimed at less technical folks what normally work in the embedded world.
It's been a long time since I worked with Pic's. But I thought that there was some eeprom type memory that you could fill with your waveform. If you are doing low frequency stuff, you can sample slowly (like 500 Hz or so), and then use your code to read a sample from memory and set the output PWM duty cycle. Rince repeat until you reach the end of your beat. Then you wait and repeat. The routine that reads and outputs the beat would always start at the beginning of the memory space where you stuck the samples, and output "N" samples. So your program would play a beat, pause for your input duration, then repeat. Sheldon |
|
|
|
#5 |
|
diyAudio Member
Join Date: Jan 2006
Location: New York
|
Sheldon,
That is a really good idea. I did a project once where I stored the sound in an external eeprom and played it back through a external DAC. It would be great to store in internal eeprom and play back through PWM. Thank you! Nora |
|
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| sound point-source models - theory | Dave Jones | Software Tools | 6 | 29th November 2010 11:15 PM |
| Sound card as source, two different monoblock amps. | beerman | Chip Amps | 4 | 17th March 2007 07:05 PM |
| Analog sound from Digital source. Possible? | Extreme_Boky | Digital Source | 36 | 9th August 2005 07:24 AM |
| Best sec.voltage for my GC? | gorko1 | Chip Amps | 0 | 31st January 2004 09:38 AM |
| New To Site? | Need Help? |
| Page generated in 0.09266 seconds (80.01% PHP - 19.99% MySQL) with 10 queries |