Modifications

Sauter à la navigation Sauter à la recherche
aucun résumé de modification
Ligne 72 : Ligne 72 :  
There are two steps to opening a file for playing. The first is to just open the file itself, then the file must be converted to a wavefile. That means the file is read and checked for a wavetable header. To open a file, you just need the name, you can pass in a string such as "MYSOUND.WAV" or read through the directory and use the name returned from '''get_next_name_in_dir()'''. Since long names arent supported (to keep the library smaller) you may want to use ls() function above to see what the 8.3 format name of the file is.
 
There are two steps to opening a file for playing. The first is to just open the file itself, then the file must be converted to a wavefile. That means the file is read and checked for a wavetable header. To open a file, you just need the name, you can pass in a string such as "MYSOUND.WAV" or read through the directory and use the name returned from '''get_next_name_in_dir()'''. Since long names arent supported (to keep the library smaller) you may want to use ls() function above to see what the 8.3 format name of the file is.
   −
<nowiki>AF_Wave card;
+
<nowiki>AF_Wave card;
 
File f;
 
File f;
 
Wavefile wave;      // only one!
 
Wavefile wave;      // only one!
Ligne 89 : Ligne 89 :     
   ...
 
   ...
} >3
+
}
 
</nowiki>
 
</nowiki>
   Ligne 111 : Ligne 111 :     
[http://www.ladyada.net/make/waveshield/examples.html See here for more information.]
 
[http://www.ladyada.net/make/waveshield/examples.html See here for more information.]
 +
 +
== Saving & restoring the play position ==
 +
 +
If, say, you want to know where along in the wave file you are, that information is also available in '''wave.getSize()''' (the number of bytes in the entire wave) and wave.remainingBytesInChunk (how many bytes are left to play)
 +
 +
You can set the current place to play from using '''wave.seek()''', the Arduino will immediately start to fastforward to that location. For example, '''wave.seek(0)''' will take you to the beginning, '''wave.seek(wave.getSize()/2)''' will take you to the middle of the file.
 +
 +
== Volume adjust ==
 +
 +
You can change the volume of the audio 'digitally' on the fly. Note that this doesn't change the volume control potentiometer, it actually just reduces the digital values going to the DAC. Thus the quality of the audio will be degraded. However, it may come in handy so it has been included. Since it slows down playback a bit, it is not enabled by default. To enable digital volume control, open up '''wave.cpp''' in the library folder and look for the line '''#define DVOLUME 0''' and change the 0 to a 1. Then delete all the files in the library folder that end with .o, this will force the software to recompile the library when the sketch is compiled.
 +
 +
The volume is controlled by a variable in the Wavefile object. For example, if you have '''Wavefile wave''' at the top of your sketch, then you can set the volume by calling wave.volume = 4. The volume can be set from 0 to 12. A volume value of 0 is maximum, and 12 is silence. Anything higher than 12 will be the same as 12.
 +
 +
[http://www.ladyada.net/make/waveshield/examples.html See here for more information].
29 917

modifications

Menu de navigation