Show Posts
Pages: 1 [2] 3 4 5
16  Using Arduino / Audio / Re: Sampling audio + exporting to some audible format on: March 16, 2013, 10:01:39 am
Hi, usually even when sampling at 12 bit, you use a 16 bit variable to store the sample. You can dump those 16 bit samples without any header to a binary file eg. on SD card connected to your Arduino. Using Audacity's Raw-Import feature you can then open the file on PC. Audacity will ask you some questions about sample rate and resolution at import, usually after a little bit of figuring around you will find the right settings quickly. You can then do some audio editing and save the file as a .wav file in Audacity.
17  Using Arduino / Audio / Re: Arduino 0..5V => -10V to 10V on: March 12, 2013, 06:57:37 pm
Hi, there are many tutorials about how to use Operational amplifiers in the internet, just google, read and learn. Using the free software LTSpice you can also simulate such things. Operational amplifiers, short term OpAmps, are what you need for your purpose. The AD712 is a good but not very cheap candidate for your purpose, I did something very like the same with these things. Go for a +/-15V and not +/-10V supply because those OpAmps don't work well when they should output something near their power rails. By using the simple cuircuit-blocks with OpAmps (you even find those on Wikipedia) do a first block that subtract 2.5V from the input - or alternatively: add -2.5 which does the same. This way you can get from +0..+5V to -2.5...+2.5V. Then put the signal through an non-inverting amplifier (done with OpAmp) that has a gain of 4 and you are done. 
18  Using Arduino / Audio / Re: New library for PWM playback from SD cards: SimpleSDAudio on: March 08, 2013, 06:39:00 pm
Hi
@manmachine: Hm, I thought about my quick solution and it is wrong - the issue is that the buffer is completely empty when issuing play and that play first reads a whole sector of 512 bytes from card before it starts playback again. This should lead to a fast but not gapless start. I think it will need a bigger overwork to get around this. I could think about modifying the lib to read the sectors byte-wise which will make the lib slower but more flexible. Audio processing will then become possible like gapless playback, fine-tuned playback tempo and mixing. But the lib might be then not as simple to use as now.

@meow...: Please provide more info what is working and what not. Error code of lib or just no sound? Or just no sound in bigger software project?
19  Using Arduino / Audio / Re: New library for PWM playback from SD cards: SimpleSDAudio on: March 06, 2013, 04:26:18 pm
Hi,
sorry, I did the patch using a too old local copy of the library on my smartphone on-the-go and got an too old lib file. Now I edited my former post, please try to apply the patch again on SimpleSDAudio-Lib V1.03 (the current one). This time I tested it a little. Unfortunately actually there is no flag that tells you if the file played at least once...
Please try again and tell me if it is working for you.

BTW: The patch catches the moment when the worker function puts the last sector (or part of it) of the audio file in the playback buffer. In this case, it waits endless (and therefore precise) until the buffer is completely empty (_Buflen == 0). In this moment it triggers the play() function, which starts the playback again. This is how the play() function works - if playback is still playing it restarts playing from start again (done by calling internally the stop() function). The stop() function resets all the pointer and the buffer for the playback. 

Tuttut
20  Using Arduino / Audio / Re: New library for PWM playback from SD cards: SimpleSDAudio on: March 05, 2013, 07:45:13 pm
Hi,
there is no standard way, but you can try this patch (untested yet!)

Code:

void SdPlayClass::worker(void) {
  if(!_WorkerRunning && _pBuf && _fileinfo.Size) {
    uint16_t buflencpy;
    _WorkerRunning = 1;
    ATOMIC_BLOCK(ATOMIC_RESTORESTATE)
    {
      buflencpy = _Buflen;
    }     
    if(_fileinfo.ActBytePos < _fileinfo.Size) {
        // At least space for 1 sector?
        if(buflencpy < _BufsizeMinus512) {
            int16_t ret;
            ret = SD_L1_ReadBlock(_fileinfo.ActSector++, _pBuf + _Bufin);
            if(!ret) {
               uint32_t BytesLeft = _fileinfo.Size - _fileinfo.ActBytePos;
               _Bufin += 512;
               _fileinfo.ActBytePos += 512;
               if(_Bufin >= _Bufsize) _Bufin -= _Bufsize;
               if(BytesLeft > 512UL) {
                   ATOMIC_BLOCK(ATOMIC_RESTORESTATE)
                   {
                     _Buflen += 512;
                   }
                } else {
                   ATOMIC_BLOCK(ATOMIC_RESTORESTATE)
                   {
                     _Buflen += BytesLeft;
                   }
                   while(1) {   
                     ATOMIC_BLOCK(ATOMIC_RESTORESTATE)
                     {
                        buflencpy = _Buflen;
                     }
                     if(buflencpy == 0) break;
                   }
                   play();                   
                }
            } else {
              stop();
              _lastError = ret;
            }
        }
    } else {
      // Playback done
      if(buflencpy <= 1) {
        stop();
      }
    }
    _WorkerRunning = 0;
  }
}


Replace the worker-function inside the lib (file SimpleSDAudio.cpp) with the one above. To stop playback you need to use stop() then.


Please try it and tell if it works...

Tuttut
21  Using Arduino / Audio / Re: i want to replay the sound on: March 05, 2013, 06:32:35 am
Hi,
please use the line if (SdPlay.init(SSDA_MODE_FULLRATE | SSDA_MODE_MONO)) only once at setup.
22  Using Arduino / Audio / Re: New library for PWM playback from SD cards: SimpleSDAudio on: March 04, 2013, 05:49:01 pm
Hi,
it is not foreseen yet to change the pitch yet, at least not in fine amounts. You can select between half or full-rate, but that's all. If you want to change the playback speed in finer amounts, it is not possible with that library yet and you wont get usable result just by changing the timer rate because the timer already runs at relatively high speed allowing only massive pitch changes.

The easiest way to do such things might be to prepare multiple files on the card each with a different pitch and play those. You can do this using an audio editor like Audacity to prepare such files.

If you really want to go the hard way it should be possible to modify the library to support different playback rates - at least two options came in mind for me, changing the playback-interrupt function or the worker-function. The worker-function is written in plain C and should be easier to modify but with rate-changing it would not be longer operating at sector boundaries. In the playback function rate changing only have influence over buffer empty speed but it is harder to understand as it is written in Asm. The algorithm I would prefer is a phase-accumulator that decides if and how many samples are skipped or repeated for every target sample...

Tuttut
23  Using Arduino / Audio / Re: New library for PWM playback from SD cards: SimpleSDAudio on: February 26, 2013, 12:25:14 pm
Hi, it seems that is still something wrong, either with wiring or something else.

Regarding post 145: If you build your voltage dividers correctly and assuming that you are not driving MISO as output you should not measure more than 3.3 - 3.6v anywhere on the SD card.

Please also check:
1.  You use a SD or SDHC card, but not SDXC. Old MMC cards may work - not tested.
2.  You use Arduino IDE 1.0 or up to 1.0.3, but not 1.5 (the beta version only for Due)
3.  If you use a ATmega328 based Arduino, even a clone, you should use an unpatched Arduino IDE and program the Arduino using one of the boards-setting that came already with the standard IDE.
4. If all is ok, check if your Arduino is still working on all ports used by the SD card. Set ports to output and high and you should measure 3.3v at appropriate SD pins.
 
 
24  Using Arduino / Audio / Re: New library for PWM playback from SD cards: SimpleSDAudio on: February 22, 2013, 04:44:51 pm
Ok, at least this Arduino clone has a ATmega328, better than the one with the plus at the end. If you do your wiring correct and with levelshifters it should work with the lib.
25  Using Arduino / Audio / Re: New library for PWM playback from SD cards: SimpleSDAudio on: February 22, 2013, 04:09:23 pm
Hi,
I think both voltage dividers will work, if you don't have those 1.8k and 3.3k resistors also the 10k/4k7 solution should do it. BUT: Do you really have a CrApDuInO+gizDuino+ (the plus version)? In such a case please tell me exactly how the menu item under "Board" inside Arduino-IDE is called that you use. I can help you to get it running even on such strange Arduino board but it will need some "special handling".
26  Using Arduino / Audio / Re: New library for PWM playback from SD cards: SimpleSDAudio on: February 22, 2013, 03:31:25 pm
Another thing: I don't like the solutions from sparkfun levelshifter site because most of them are pretty slow. Better use a voltage divider with two resistors per line as described in SimpleSDAudio.h. This is proven to work even at fast SPI speeds as required for my lib.
27  Using Arduino / Audio / Re: New library for PWM playback from SD cards: SimpleSDAudio on: February 22, 2013, 03:16:59 pm
Hi,
is it so hard to believe that your board is running on 5V and not on 3.3V even that #*&! website says something different? That you measured the 3.3V line at 4.2V is a sign that your SD card is fighting a deathly battle against the 5V. What happens is the following: The SD card is connected to 3.3V at VCC, but at 5V at one of the other pins. An internal protection diode in the card tries to clamp the excess voltage at the pin with 5V to the 3.3V supply, but that supply is also weak because the crapduino uses some 3.3V from the USB-seriell-converter chip instead of a powerful extra regulator. This way the 3.3V regulator looses the battle and its output voltage rises to 5V minus the typical diode foreward-voltage of 0.7-0.8V = 4.2V. This is not how it should be done! You can destroy your AVR, the USB-Seriell-Converter or the SD card. I don't know how long this battle can take place and who will win, but you might have already broken something. Hint: Try if your SD card still works within a PC before spending more time frying stuff...

Believe it: YOU NEED LEVEL-SHIFTERS or a SD-shield that has those!
28  Using Arduino / Audio / Re: New library for PWM playback from SD cards: SimpleSDAudio on: February 22, 2013, 02:16:52 pm
Hi, I looked over the Gizdino+ schematic: It runs on 5V, so you need level-shifters and you should test the 3v3 pin before with a multimeter to ensure that at least there is 3.3v. Second, the gizdino+-thing has sanguino pinmap, but datasheet says that there is a mapping for arduino-compatibility. Whatever, in the end you must ensure that the hardware spi pins are connected correctly to the card, so mosi to mosi, miso to miso, clk to clk and cs to pin 4 - but i dont know if in arduino or sanguino or gizdino numbering. Even if that is all correct i dont know if it will work because that clone is not very compatible to arduino. better go for the real one - at least take one with the correct cpu. the gizdino-non-plus version may work, but beware - the statement that it is 3.3v seems to be a bad typo to me...
29  Using Arduino / Audio / Re: New library for PWM playback from SD cards: SimpleSDAudio on: February 16, 2013, 08:33:21 am
1: I don't know if the lib work with ATmega324 and I don't know Arduinos with that processor. The typical processor is ATmega328.

2: Have you use level-shifters or does your Arduino run with 3.3V only? If the Arduino is 5V you need level-shifters or you could broke your SD card. The simplest way to build a level-shifter is using two resistors for every of the four input pins at the SD card. A description can be found in file SimpleSDAudio.h.

3: You have to power the SD card as well - connect GND to pin 3 and 6 of SD-card and connect pin 4 to the 3.3V output of the Arduino.

4: If there is no sound try the example BareMinimumWithDebug first and look at the output from the serial port. This can give you an indication if your wiring is still wrong or if there is something wrong with the filesystem on card or the file. You can post this output here in the forum to get more help.
30  Using Arduino / Audio / Re: New library for PWM playback from SD cards: SimpleSDAudio on: February 13, 2013, 12:09:38 pm
The audio lib uses a timer and the hardware SPI. I2C is often a different hardware in uC, so I2C should still work beside the audio lib. For additional SPI devices also software-SPI might be an option and that way it should be possible to run SPI devices on pins not already used by the audio lib as well. So just give it a try.
Pages: 1 [2] 3 4 5