Différences entre versions de « ADAFRUIT-AUDIO-FX-port-série »

De MCHobby - Wiki
Sauter à la navigation Sauter à la recherche
Ligne 29 : Ligne 29 :
 
Placez le répertoire {{fname|Adafruit_Soundboard}} dans votre répertoire {{fname|répertoire_des_croquis_arduino/libraries/}}.
 
Placez le répertoire {{fname|Adafruit_Soundboard}} dans votre répertoire {{fname|répertoire_des_croquis_arduino/libraries/}}.
 
Vous pourriez avoir besoin de créer le sous répertoire {{fname|libraries}} si ce dernier n'existe pas encore. Redémarrez votre Editeur Arduino.
 
Vous pourriez avoir besoin de créer le sous répertoire {{fname|libraries}} si ce dernier n'existe pas encore. Redémarrez votre Editeur Arduino.
 +
 +
En cas de besoin, vous pouvez consulter notre tutoriel "[[Installation_d%27un_librairie_Arduino|Installer des bibliothèques Arduino]]
  
 
== Charger le croquis de démo ==
 
== Charger le croquis de démo ==

Version du 31 décembre 2015 à 14:16


MCHobby investit du temps et de l'argent dans la réalisation de traduction et/ou documentation. C'est un travail long et fastidieux réalisé dans l'esprit Open-Source... donc gratuit et librement accessible.
SI vous aimez nos traductions et documentations ALORS aidez nous à en produire plus en achetant vos produits chez MCHobby.

Utiliser le port série

Si pour une raison quelconque vous ne voulez pas utiliser le mode de déclenchement, parce que vous avez besoin d'un système de lecture audio plus complexe, alors vous pouvez utiliser le mode série. Le mode série permet de contrôler la carte son par l'intermédiaire du port série. Le mode série permet de à un microcontrôleur équipé d'un UART TTL 9600 d'envoyer des commandes sur le module.

Les carte audio d'Adafruit peuvent être utilisées en mode UART ou en mode GPIO (avec des boutons d'activation) - mais pas les deux en même temps!

Nous allons utiliser un Arduino comme exemple mais vous pouvez adapter les informations suivantes (et la bibliothèque) à n'importe quel autre microcontroleur.

{{{2}}}
Crédit: AdaFruit Industries www.adafruit.com

Bibliothèque Arduino

Si vous avez un Arduino, vous pouvez réaliser les branchements comme sur l'image ci-dessus. Cela permet de contrôler la carte son à l'aide du simple programme d'exemple proposé par Adafruit.

Voici les raccordements:

  • UG sur la masse/GND (pour activer le mode série),
  • TX sur Arduino #5,
  • RX sur Arduino #6,
  • RST sur Arduino #4

Vous aurez besoin de télécharger la bibliothèque Adafruit_Soundboard depuis le dépôt GitHub pour prendre le contrôle de la puce de la carte son. Vous pouvez télécharger la bibliothèque en visitant le dépôt GitHub d'Adafruit et télécharger (Download) manuellement l'archive -OU- plus simplement cliquer sur le bouton de téléchargement ci-dessous.

Download-icon.pngTéléchargez la bibliothèque Soundboard d'Adafruit

Décompressez le contenu de l'archive ZIP puis renommé le répertoire décompressé comme Adafruit_Soundboard. Verifiez que le répertoire Adafruit_Soundboard contienne bien le fichier Adafruit_Soundboard.cpp et Adafruit_Soundboard.h

Placez le répertoire Adafruit_Soundboard dans votre répertoire répertoire_des_croquis_arduino/libraries/. Vous pourriez avoir besoin de créer le sous répertoire libraries si ce dernier n'existe pas encore. Redémarrez votre Editeur Arduino.

En cas de besoin, vous pouvez consulter notre tutoriel "Installer des bibliothèques Arduino

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

{{{2}}}
Crédit: AdaFruit Industries www.adafruit.com

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

{{{2}}}
Crédit: AdaFruit Industries www.adafruit.com

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:

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

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

{{{2}}}
Crédit: AdaFruit Industries www.adafruit.com

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

{{{2}}}
Crédit: AdaFruit Industries www.adafruit.com

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)

{{{2}}}
Crédit: AdaFruit Industries www.adafruit.com

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

{{{2}}}
Crédit: AdaFruit Industries www.adafruit.com

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!

{{{2}}}
Crédit: AdaFruit Industries www.adafruit.com

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

{{{2}}}
Crédit: AdaFruit Industries www.adafruit.com

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!

{{{2}}}
Crédit: AdaFruit Industries www.adafruit.com

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'

{{{2}}}
Crédit: AdaFruit Industries www.adafruit.com

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!


Source: Adafruit Audio FX Sound board Crédit: AdaFruit Industries

Créé par Ladyada pour AdaFruit Industries.
Traduit par Meurisse D. pour MCHobby.

Toute référence, mention ou extrait de cette traduction doit être explicitement accompagné du texte suivant : «  Traduction par MCHobby (www.MCHobby.be) - Vente de kit et composants » avec un lien vers la source (donc cette page) et ce quelque soit le média utilisé.

L'utilisation commercial de la traduction (texte) et/ou réalisation, même partielle, pourrait être soumis à redevance. Dans tous les cas de figures, vous devez également obtenir l'accord du(des) détenteur initial des droits. Celui de MC Hobby s'arrêtant au travail de traduction proprement dit.

Traduit avec l'autorisation d'AdaFruit Industries - Translated with the permission from Adafruit Industries - www.adafruit.com