Modifications

Sauter à la navigation Sauter à la recherche
7 992 octets ajoutés ,  30 décembre 2015 à 20:02
Page créée avec « {{ADAFRUIT-AUDIO-FX-NAV}} {{traduction}} == Utiliser le port série == {{bloc-etroit|text=If for some reason you don't want to use the trigger mode, say you need some mo... »
{{ADAFRUIT-AUDIO-FX-NAV}}

{{traduction}}

== Utiliser le port série ==
{{bloc-etroit|text=If for some reason you don't want to use the trigger mode, say you need some more complex audio playing, you can use serial audio control. This allows any microcontroller with 9600 baud TTL UART to send commands to the module.

'''All Adafruit Soundboards can be used in either UART mode or GPIO (button) mode''' - but ''not'' at the same time!

We'll demonstrate with an Arduino, but you can use any microcontroller with a little adaptation}}

{{ADFImage|ADAFRUIT-AUDIO-FX-port-série-01.jpg}}

== Bibliothèque Arduino ==
If you have an Arduino, you can wire it as seen above to control the sound board via our simple menu example
* UG to Ground,
* TX to #5,
* RX to #6,
* RST to #4

To begin controling the motor chip, you will need to [https://github.com/adafruit/Adafruit_Soundboard_library download the Adafruit_Soundboard Library from our github repository]. You can do that by visiting the github repo and manually downloading or, easier, just click this button to download the zip.

{{download-box|Téléchargez la bibliothèque Soundboard d'Adafruit|https://github.com/adafruit/Adafruit_Soundboard_library/archive/master.zip}}

Rename the uncompressed folder {{fname|Adafruit_Soundboard}} and check that the {{fname|Adafruit_Soundboard}} folder contains {{fname|Adafruit_Soundboard.cpp}} and {{fname|Adafruit_Soundboard.h}}

Place the {{fname|Adafruit_Soundboard}} library folder your {{fname|arduinosketchfolder/libraries/}} folder.
You may need to create the libraries subfolder if its your first library. Restart the IDE.

== Charger le croquis de démo ==
Now you can open up '''File->Examples->Adafruit_Soundboard->menu''' and upload to your Arduino wired up to the breakout

{{ADFImage|ADAFRUIT-AUDIO-FX-port-série-10.png}}

Then open up the serial console at 115200 baud to interact!

{{ADFImage|ADAFRUIT-AUDIO-FX-port-série-11.png}}

== Utilisation générale ==
For connections we recommend at a minimum

* Connect '''UG''' to '''GND''' (to start the sound board in Uart mode)
* Connect '''RX''' to the data-output pin from the microcontroller into the sound board
* Connect '''TX''' to the data-output pin to the microcontroller from the sound board
* Connect '''RST''' to another microcontroller pin, when toggled low, it will reset the sound board into a known state

If you want to know when sound is being played, the '''ACT''' pin is au '''LOW''' when audio is playing - this output also controls the red ACT LED

You can use 3.3V or 5V logic on the '''RX''' pin, it has a level shifter. TX is output at 3.3V which can be read from a 3.3V or 5V logic. For the '''RST''' pin, it's 3.3V and has a pullup. To reset the board, set the microcontroller pin to low, then an output, then back to an input like so:

<nowiki> digitalWrite(reset_pin, LOW);
pinMode(reset_pin, OUTPUT);
delay(10);
pinMode(reset_pin, INPUT);
delay(1000); // give a bit of time to 'boot up'</nowiki>

After reset, the sound board will print out a bunch of info

{{ADFImage|ADAFRUIT-AUDIO-FX-port-série-20.png}}

First line tells you when this firmware was written (10/21/14) and the name of the board - the name is the same for all the SFX boards right now, but you may have a different firmware date

The second line will read '''FAT''' and then a 8 digit hexadecimal number, which will tell you the size of the partition that all the files are on in 512 byte sectors. E.g. here 0x7FC0 = 32,704. 32704 * 512 bytes = 16,744,448 (16 MB)

Third line will read '''Files''' and then a 5 digit decimal # of files that are on the Soundboard. here, we see it has 16 files available.

== Commandes ==

There are a few commands, in two 'sets' - one set is commands that can be run in IDLE mode, and the other is commands that can be run in PLAY mode.

== Commandes en mode IDLE ==
These are commands you can use when audio is not being played!

=== Liste des fichiers ===

* L - Send "L\n" (L plus new line) to list files

{{ADFImage|ADAFRUIT-AUDIO-FX-port-série-30.png}}

files will be listed in following format:

FILENAMEEXTfilesizeinbytes

Where "FILENAMEEXT" is the full 8.3 file name of each file, with no dot, if you have a file with shorter than 8 characters, it will be padded with spaces.

The filesize is in bytes, and is padded with zeros as well

=== Modifier le volume ===
You can adjust volume from 0 (silent) to 204 (loudest) in 2-increments. To increase the volume, send +\n (plus symbol plus new line). to decrease volume send -\n (minus symbol plus new line) and it will reply with the new volume (5 ascii characters, two of which are going to be zeros and then three digits of volume, plus a new line)

{{ADFImage|ADAFRUIT-AUDIO-FX-port-série-40.png}}

=== Jouer une piste par numéro ===

Each track has a number with respect to when it was copied onto the SD card, starting with track #0, these are in the order that the tracks are printed out when you send 'L' for list tracks.

The fastest way to play a track is by the track number, send '''#NN\n''' (# symbol, then the number of the track, and end with a new line). E.g. to play the first track (track #0) send #0\n and for the 11th track, send '''#10\n'''

{{ADFImage|ADAFRUIT-AUDIO-FX-port-série-50.png}}

If the file wasnt found, it will reply with '''NoFile\n'''

If the file is found, the sound board will reply with '''playNNNNNFILENAMEEXT\n'''

where NNNNN is the track number, and FILENAMEEXT is the 11-character file name (8.3 without the dot)

When the file is done, it will print '''done\n''' to let you know

=== Jouer une piste par nom ===
Maybe you want to just play the track by a name, not number. No problem! You can do that with the '''P''' command

Send '''PFILENAMEEXT\n''' - 'P' plus the 11-character file name (8.3 without the dot) then a new line. If the filename is shorter than 8 characters, fill the characters

For example, to play '''T00NEXT5.WAV''' send '''PT00NEXT5WAV\n''' and to play '''T09.OGG''' send '''PT09 OGG\n'''

If the file wasnt found, it will reply with '''NoFile\n''' otherwise it will reply as above, with '''playNNNNNFILENAMEEXT\n'''

== Commandes en mode lecture ==
OK now that you are playing audio, you can do stuff during play, these are not available in IDLE mode

=== Pause et reprise ===
You can pause at any time by sending the = character, no new line required. To restart playback, send the > character

These character will be echo'd back to you on the UART so you know they were received!

{{ADFImage|ADAFRUIT-AUDIO-FX-port-série-60.png}}

=== Arrêter la lecture ===
You can also stop instantly by sending a '''q''' (for 'quit') and the audio will stop and return back to IDLE mode

{{ADFImage|ADAFRUIT-AUDIO-FX-port-série-70.png}}

=== Position de la lecture ===
You can query how much time has been spent playing the current track by sending an t character

You will get a response which is 5 digits a : and then another 5 digits. The first 5 digits are seconds currently elapsed, the second half is supposed to be the codec's report of total play time but so far we've always just gotten 0's so we suggest just using the first set of digits (current playback in seconds)

Please note this is a blocking operation. Doing it too much can cause your audio to stutter!

{{ADFImage|ADAFRUIT-AUDIO-FX-port-série-80.png}}

== Taille de fichier et autre ==
Finally, you can query the size of the file and how far along you are in it, which is sort of like how much you've got left to play but of course, for compressed OGGs may vary a bit. Still, might be handy!

You can get the file size and remaining bytes by sending an 's'

{{ADFImage|ADAFRUIT-AUDIO-FX-port-série-90.png}}

The sizes are reported in decimal bytes, 10 digits long seperated by a /

The first number is remaining bytes and the second number is total size.

Please note this is a blocking operation. Doing it too much/fast can cause your audio to stutter!

{{ADAFRUIT-AUDIO-FX-TRAILER}}
29 917

modifications

Menu de navigation