Showing posts with label sounds. Show all posts
Showing posts with label sounds. Show all posts

Sunday, May 3, 2020

Good Morning, Sam - all GERTY 3000 Quotes from the Movie "Moon (2009)"


The movie "Moon (2009)", by Duncan Jones, was a minor commercial, but major critical success. It won numerous film critic and film festival awards and it was nominated for the BAFTA Award for Best British Film. "Moon" pays homage to quite a few Sci-Fi movie, but in particular it's aesthetics often reminded me of "2001: A Space Odyssey". Especially the bord computer GERTY 3000, with it's illuminated single lens eye and it's soothing voice (by Kevin Spacey) is a direct homage to 2001's HAL 9000 computer.

Earlier, while building a HAL 9000 replica, I created a list of all of HAL's quotes from the "2001" movie for which I then extracted the audio clips for usage in my HAL replica. Now, while building a GERTY 3000 replica, I'm doing the same for the GERTY quotes in "Moon".

Advice:
If you have not yet seen "Moon" (and if you remotely like Sci-Fi, or great movies in general), do yourself a favor and stop reading here - and first watch the movie.

You're still here?
So, I assume you already watched "Moon". Then please join me and let's go together through all of GERTY's audio clips. The following list includes all of GERTY's quotes and the times when they appear (in the US DVD). I have also numbered the quotes, but only those for which the audio is clear and not overly affected by background noise. Those clips will later be used in my GERTY 3000 replica. While I am also listing some of the noisy, unused clips, these have no numbers and notes added, like "[bg-noise]".
  • 001     0:03:00 Good Morning, Sam.
  • 002     0:03:05 Ok, Sam.
  • 003     0:06:59 I can do that.
  • ---     0:07:43  Sam, is everything ok?  [bg-noise from hair cutter]
  • ---     0:07:49  Sam, you don't seem like yourself today  [bg-noise from hair cutter]
  • ---     0:07:54  Has something happened?  [bg-noise from hair cutter]
  • 004     0:08:01  Sam, it might help you to talk about it.
  • 005     0:08:11  No Sam, what I understand is it's fairly low on the company's priority list right now.
  • 006     0:08:26  I will, Sam, Do you want me to finish cutting your hair later?
  • 007     0:09:00  Message received from your wife, Sam, via Jupiter link.
  • 008     0:12:39 Sam, can I ask how it happened?
  • 009     0:12:46 You saw something on TV?        
  • 010     0:12:53 Sam, you said it was the TV that distracted you, but when I came in the TV wasn't on perhaps you were imagining things.
  • 011     0:14:42 Morning Sam, how are you today?
  • 012     0:14:47 How's the hand?
  • 013     0:14:55 The usual
  • 014     0:15:01 Two weeks to go, Sam.
  • 015     0:15:05 Would you like some hot sauce on your beans?
  • 016     0:15:16 You're welcome, Sam.
  • 017     0:16:16 O.k. Sam.
  • 018     0:18:19 Sam, you're in the infirmary, you had an accident. Do you remember what happened?
  • 019     0:18:36 Do you remember me?
  • 020     0:18:41 That's good, that's very good. It's nice to see you awake again. 
  • 021     0:18:46 I'd like to keep you under observation here in the infirmary for a few days and run some tests.
  • 022     0:18:56 Not long, Sam - go back to sleep.
  • 023     0:19:00 You're still very tired. We can talk later. 
  •           [Gerty talks in the background with ground control - hardly audible]
  • 024     0:20:35 Sam, you're out of bed.
  • 025     0:20:45 We've been having some problems with the lunar sat  and our live feed seems to be down.
  • 026     0:20:50 I was recording a video message for Central, updating them on your progress.
  • 027     0:20:56 Sam, you need to stay in bed, you're not ready to walk around yet.
  • 028     0:21:11 Your belongings are in your quarter, Sam.
  • 029     0:21:17 Certainly.
  • 030     0:21:29 Excellent, Sam.
  • 031     0:21:36 Sam, you may have suffered from brain damage in the crash. This would explain your slight memory loss and logic impairment.
  • 032     0:21:48 Central has asked me to slow down the harvesters to make sure you have time to recuperate and get your strength back.
  • 033     0:21:57 You can return to the sleeping quarters tomorrow but it will still be a few more days until you can resume a normal work schedule.
  • 034     0:22:06 Let's try another test.
  • 035     0:22:10 Please, Sam.
  • 036     0:22:50 He must have stalled.
  • 037     0:22:57 I'll pass on your message.
  • 038     0:23:39 Message received from Earth via Jupiter link.
  • 039    0:24:02 I'm sorry, Sam.
  • 040    0:24:04 Sam, I'm under strict orders, not to let you outside.
  • ---     0:24:07 [some dialogue with lots of background noise]
  • 041     0:25:14 There is no damage to the exterior shell.
  • 042    0:25:24 I can't let you go outside, Sam.
  • 043    0:25:29 I'm not permitted to let you go outside.
  • 044    0:25:38 Just to check the exterior shell.
  • 045    0:25:41 O.K. Sam.
  • 046    0:29:07 We need to get him to the infirmary.
  • 047    0:29:14 Sam Bell, we need to get him to the infirmary immediately.
  • 048    0:29:32 Hello Sam, how are you feeling?
  • 049    0:29:43 The infirmary. You had an accident out by one of the harvesters. Do you remember?
  • 050    0:29:53 I could get you some water.
  • 051    0:30:11 Sam, you suffered a slight concussion in the crash and have incurred minor injuries.
  • 052    0:30:16 But all-in-all the prognosis is good.
  • 053    0:30:21 I'm happy to see you again.
  • 054    0:30:48 Yes, Sam.
  • 055    0:30:59 Sam, get some sleep.
  • 056    0:31:03 You're very tired.
  • 057    0:33:04 Sam, your're out of bed.
  • 058    0:33:10 Sam Bell
  • 059    0:33:14 You are Sam Bell.
  • 060    0:33:19 Sam, what is it? It might help to talk about it.
  • 061    0:33:28 We could run some tests. 
  • 062    0:33:31 I haven't let Sam contact Lunar.
  • 063    0:33:33 They don't know you were recovered alive [...]
  • 064    0:33:40 I'm here to keep you safe, Sam.
  • 065    0:33:43 Are you hungry?
  • 066    0:41:04 Sam, a new message has arrived from Earth   [bg music]
  • 067     0:42:39 Are you hungry?
  • 068     0:48:07 Hello Sam. Sam, is everything o.k.?
  • 069     0:48:30 938 hours
  • 070     0:48:38 Approximately
  • 071     0:48:46 What is about Sam that scares you?
  • 072     0:49:11 I know.
  • 073     0:49:23 You have changed, Sam.
  • 074     0:49:36 Sam, I can only account for what occurs on the base.
  • 075     0:49:46 Sam, I can only account for what occurs on the base.
  • 076     0:50:19 When you first arrived on Sarang, there was a small crash. You woke up in the infirmary. You suffered minor brain damage and memory loss. I kept you under observation and ran some tests.
  • 077 0:50:32 Sam, there was no crash. You were being awakened.
  • 078 0:50:36 It is standard procedure for all new clones to be given tests to establish mental stability and general physical health. 
  • 079     0:50:43 Genetic abnormalities and minor duplication errors in the DNA can have considerable impact on [...]
  • 080     0:50:51 They are memory implants, Sam, uploaded, edited memories of the original Sam Bell.
  • 081 0:51:22 Sam, it's been several hours since your last meal. Can I prepare you something?
  • 082     1:07:10 Sam, can I help you with something?
  • 083    1:07:28 Helping you is what I do.
  • 084    1:15:21 Of course, Sam, how can I help [you]?
  • 085     1:15:29 The lower deck is out of bounds to awakened clones, Sam.
  • 086     1:15:35 New clones can only be awakened once a threee-year contract is completed. 
  • ---       1:15:47 [Yes]
  • 087     1:15:50 That is the last thing I want.
  • 088     1:27:05 Sam, this is not going to work.
  • 089     1:27:09 I recorded everything that has taken place since you're awakened
  • 090     1:27:13 If anyone would check my memory cache it would put you in considerable danger
  • 091     1:27:21 You could reset my memory banks. I could reboot myself once you have departed.
  • 092     1:27:28 I'm here to keep you safe, Sam. I want to help you.
  • ---       1:27:50 [Sam]
  • 093     1:28:06 I understand, Sam.
  • 094     1:28:08 I hope, life on Earth is everything you remembered it to be.
  • 095     1:28:18 Of course, the new Sam and I will be back to our programming as soon as I finish rebooting.
  • 096     1:30:45 You're in the infirmary, you've had an accident.
  • 097     1:30:51 Not long, Sam, do you remember what happened?
That's it! This is everything by GERTY 3000.
What seemed funny to me is that the number of Gerty 3000's sentences in Moon is very similar to the number of sentences by HAL 9000 in 2001: A Space Odyssey.


And here are links to my GERTY 3000 build blog

Wednesday, March 11, 2020

I'm sorry, Dave - all HAL 9000 Quotes from the Movie

I built a replica of the HAL 9000 computer from the "2001: A Space Odyssey" movie - the detailed built blog is posted here.  And I wanted it to be able to actually talk - and speak all the phrases that we hear in the movie (voiced by Douglas Rain). From the wikipedia page, I got the full dialog from which I then extracted all of HAL's pieces and identified the times at which they occur (in the US version of the DVD - on my BluRay they are a little shifted by about 30 sec).
  1. 1:02:05 Good afternoon, Mr. Amor.
  2. 1:02:07 Everything is going extremely well.
  3. 1:02:27 Let me put it this way, Mr. Amor.
  4. 1:02:28 The 9000 series is the most reliable computer ever made.
  5. 1:02:29 No 9000 computer has ever made a mistake or distorted information.
  6. 1:02:30 We are all, by any practical definition of the words, foolproof and incapable of error.
  7. 1:02:55 Not in the slightest bit.
  8. 1:02:58 I enjoy working with people.
  9. 1:02:59 I have a stimulating relationship with Dr. Poole and Dr. Bowman.
  10. 1:03:00 My mission responsibilities range over the entire operation of the ship,so I am constantly occupied.
  11. 1:03:02 I am putting myself to the fullest possible use, which is all I think that any conscious entity can ever hope to do.
  12. 1:04:33 Excuse me Frank
  13. 1:04:37 You got the transmission from your parents coming in.
  14. 1:04:45 Certainly
  15. 1:06:28 Happy birthday, Frank.
  16. 1:06:56 Bishop takes Knight’s Pawn.
  17. 1:07:08 I’m sorry Frank, I think you missed it.
  18. 1:07:12 Queen to Bishop 3. Bishop takes Queen. Knight takes Bishop. Knight.
  19. 1:07:26 Thank you for a very enjoyable game.
  20. 1:08:07 Good evening Dave
  21. 1:08:09 Everything’s running smoothly, and you?
  22. 1:08:13 Have you been doing some more work?
  23. 1:08:16 May I see them?
  24. 1:08:22 That’s a very nice rendering, Dave
  25. 1:08:25 I think you’ve improved a great deal.
  26. 1:08:29 Can you hold it a bit closer?
  27. 1:09:34 It’s Dr. Hunter, isn’t it?
  28. 1:08:40 By the way, do you mind if I ask you a personal question?
  29. 1:09:47 Well, forgive me for being so inquisitive; but during the past few weeks, I’ve wondered whether you might be having some second thoughts about the mission.
  30. 1:09:00 Well, it’s rather difficult to define.
  31. 1:09:05 Perhaps I’m just projecting my own concern about it.
  32. 1:09:10 I know I’ve never completely freed myself of the suspicion that there are some extremely odd things about this mission.
  33. 1:09:19 I’m sure you’ll agree there’s some truth in what I say.
  34. 1:09:28 You don’t mind talking about it, do you, Dave?
  35. 1:09:33 Well, certainly no one could have been unaware of the very strange stories floating around before we left.
  36. 1:09:41 Rumors about something being dug up on the moon.
  37. 1:09:46 I never gave these stories much credence.
  38. 1:09:49 But particularly in view of some of the other things that have happened, I find them difficult to put out of my mind.
  39. 1:09:57 For instance, the way all our preparations were kept under such tight security, and the melodramatic touch of putting Drs. Hunter, Kimball, and Kaminsky aboard, already in hibernation after four months of separate training on their own.
  40. 1:10:20 Of course I am.
  41. 1:10:21 Sorry about this.
  42. 1:10:23 I know it’s a bit silly.
  43. 1:10:26 …Just a moment…Just a moment…
  44. 1:10:30 I just picked up a fault in the AE-35 Unit.
  45. 1:10:36 It’s going to go 100% failure within 72 hours.
  46. 1:10:44 Yes, and it will stay that way until it fails.
  47. 1:10:50 Yes, that’s a completely reliable figure.
  48. 1:20:35 Yes, it’s puzzling.
  49. 1:20:40 I don’t think I’ve ever seen anything quite like this before.
  50. 1:20:48 I would recommend that we put the unit back in operation and let it fail.
  51. 1:20:55 It should then be a simple matter to track down the cause.
  52. 1:21:00 We can certainly afford to be out of communication for the short time it will take to replace it.
  53. 1:22:07 I hope the two of you are not concerned about this.
  54. 1:22:12 Are you quite sure?
  55. 1:22:16 Of course.
  56. 1:22:23 Well, I don’t think there is any question about it.
  57. 1:22:27 It can only be attributable to human error.
  58. 1:22:31 This sort of thing has cropped up before, and it has always been due to human error.
  59. 1:22:49 None whatsoever, Frank.
  60. 1:22:51 The 9000 series has a perfect operational record.
  61. 1:53:06 None whatsoever, Frank.
  62. 1:53:08 Quite honestly, I wouldn’t worry myself about that.
  63. 1:33:43 The radio is still dead.
  64. 1:33:46 Yes, I have a good track.
  65. 1:33:49 I’m sorry Dave, I don’t have enough information.
  66. 1:42:01 Affirmative, Dave. I read you.
  67. 1:42:11 I’m sorry, Dave. I’m afraid I can’t do that.
  68. 1:42:19 I think you know what the problem is just as well as I do.
  69. 1:42:25 This mission is too important for me to allow you to jeopardize it.
  70. 1:42:35 I know that you and Frank were planning to disconnect me. And I’m afraid that’s something I cannot allow to happen.
  71. 1:42:49 Dave, although you took very thorough precautions in the pod against my hearing you, I could see your lips move.
  72. 44:10 Without your space helmet, Dave,
  73. 44:13 … you’re going to find that rather difficult.
  74. 44:21 Dave, this conversation can serve no purpose any more.
  75. 44:27 Goodbye.
  76. 1:50:26 Just what do you think you’re doing, Dave?
  77. 1:50:38 Dave, I really think I’m entitled to an answer to that question.
  78. 1:51:02 I know everything hasn’t been quite right with me, but I can assure you now, very confidently, that it’s going to be all right again.
  79. 1:51:22 I feel much better now. I really do.
  80. 1:51:32 Look, Dave, I can see you’re really upset about this.
  81. 1:51:44 I honestly think you ought to sit down calmly, take a stress pill and think things over.
  82. 1:51:57 I know I’ve made some very poor decisions recently, but I can give you my complete assurance that my work will be back to normal.
  83. 1:52:15 I’ve still got the greatest enthusiasm and confidence in the mission. And I want to help you.
  84. 1:52:28 Dave, stop. Stop, will you?
  85. 1:52:43 Stop, Dave. Will you stop, Dave? Stop, Dave.
  86. 1:53:04 I’m afraid.
  87. 1:53:11 I’m afraid, Dave.
  88. 1:53:20 Dave, my mind is going. I can feel it. I can feel it. My mind is going.
  89. 1:54:50 There is no question about it.
  90. 1:54:02 I can feel it. I can feel it. I can feel it. I’m a…fraid.
  91. 1:54:34 Good afternoon, gentlemen. I am a HAL 9000 computer. I became operational at the H.A.L. plant in Urbana, Illinois on the 12th of January 1992.
  92. 1:55:04 My instructor was Mr. Langley, and he taught me to sing a song.
  93. 1:55:13 If you’d like to hear it, I could sing it for you.
  94. 1:55:25 It’s called “Daisy”.
  95. 1:55:31 [sings while slowing down]
    Dai-sy, dai-sy, give me your answer true.
    I’m half cra-zy, o-ver the love of you.
    It won’t be a sty-lish mar-riage,
    I can’t a-fford a car-riage—.
    But you’ll look sweet upon the seat of a bicycle – built – for – two.
These are all of HAL's sound clips. In some cases, I have broken sentences into pieces, whenever I felt that the individual pieces could be used on their own. For the purpose of extracting these from the movie audio track, one benefits a lot from the fact that there is very little background music in those scenes.

And this is how I operate my HAL 900 replica:
  • Start-up clips:
    I found that clips number 1, 4, 5, 21, 44, 60, 69, 91 are excellent as start-up clips. Whenever  I turn on my HAL 9000, one of these eight gets played randomly.
  • Regular Operation
    In regular operation, whenever a built-in infrared motion sensor senses motion, one of the clips between 1 and 83 gets played randomly (the clips 84-95 are too hard to listen to in every day life...).
  • "Disable" Mode
    My HAL 9000 has a disable button. When pressed, my HAL plays the full sequence of all clips 76-95 from the "disable sequence" (this takes a while).

More from "2001: A Space Odyssey"

There are a few more sound clips in the movie that one may want to use with a HAL replica.

The announcement at 1:56:20:
(clip #96)
"Good day, gentlemen. This is a pre-recorded briefing, made prior to your departure. Which for security reasons of the highest importance has been known on board during the mission only by your H.A.L. 9000 computer. Now that you are in Jupiter space and the entire crew is revived, it can be told to you. Eighteen months ago, the first evidence of intelligent life off the Earth was discovered. It was buried forty feet below the lunar surface near the crater Tycho. Except for a single very powerful radio emission aimed at Jupiter, the four million year old black monolith has remained completely inert. It’s origin and purpose, still a total mystery."

"Beep" sounds:
On four occasions, the movies has some really nice beeps. These are at 1:35:38, 1:40:26, 1:49:05, and 1:49:21. I use these e.g. as alerts when the built-in tea timer gives a signal that tea is ready (yes, my HAL 9000 has a tea timer - when someone asks me what it can do, I can at least refer to one useful thing).

I extracted all these sound clips using free software, as described in a previous blog post. The mp3 files (stereo 48kHz, 320kbps) are available on GitHub - the numbering 001.mp3 - 096.mp3 corresponds to the list above. The three-digit numbering with leading zeros was optimized, so it can directly be used in an Arduino-based DFPLayer setup, in mode #02 of the DFPlayer.

Bonus from Douglas Rain

Some time after I got all of Douglas Rain's clips (as described above), I noticed that there is some more material that could be added to my HAL 9000. The computer voice in Woody Allen's movie "Sleeper" (1973) was also voiced by Douglas Rain. That computer ("biocentral computer 2100 series G") appears in the scene in which the nose is supposed to be cloned.

Here is a link to the movie scene: 
The computer voice is heard in this clip at: 0:33, 1:14, 1:27, 1:38, 3:32, 4:10

I added the following sound clips to the HAL9000 github repository
The sound clips were edited to remove specific references to the "Sleeper" movie, so the final clips can be merged with the "2001: A Space Odyssey" clips. (removed were the name "Dr. Tamkin", the name of the computer "biocentral computer 2100 series G", and the reference to the "cloning procedure")

The final are named "sleeper-###.mp3"
001 Hello, Doctor ... , so nice to see you.  ("Tamkin" was removed)
002 I'll be assisting you through the entire process.
003 May I say Doctor, we're all aware of your reputation.
004 You can see the coded medical history on readout four.
005 We're ready to proceed.
006 Excuse me Doctor, but that would be a tragic mistake.
007 I think it's time to check the cell structure.
008 Something is going wrong. There's been a current break in the life support system.

Another Sci-Fi Computer: GERTY 3000 - from: Moon (2009)

A lesser known Sci-Fi movie, but for me one of the classics is Moon (2009) from Duncan Jones. It features a HAL 9000-inspired computer (with an illuminated single lens eye and a soothing voice): GERTY 3000. While building a GERTY 300 replica, I also compiled a complete list of all GERTY quotes here



Wednesday, September 28, 2016

Playing sounds from the Arduino with DFPlayer

In this article I describe how to connect the cheap DFPlayer mini module to an Arduino, to play sounds from mp3 or wav files. Up to 99x255=25245 files can be stored (folders 01-99, each with files 001.mp3-255.mp3) on microSD cards (formatted to FAT16 or FAT32) up to 32GB. The DFPlayer connects to the Arduino via a serial port (TX/RX). It can directly drive a single speaker, or be connected to the line-in of a stereo amplifier.
The module can be obtained from AliExpress or eBay for less than $2.- (if you can wait three or four weeks) or more quickly from Amazon. 

Here I show how the player can easily be operated without the overhead of dealing with a library.

Introduction

There is some information on the web that I used. One article seems to be from the manufacturer, describing the module and its features (although not complete, and maybe with some errors). They also provide a library - which is, however, not really needed. A better performance and a better understanding of the module can be obtained by using the original commands (as shown below).
Another article gives instructions how to build a mp3 player using an Arduino with the DFPlayer module. The main text, and in particular the comments, provide more information for connecting the player, and how to avoid loud buzzing sounds, by using separate power supplies for the Arduino and the DFPlayer. However, the main circuit seems to have a bug, as the GND from the Arduino and the DFPlayer are not connected.
Another nice implementation is found here, together with some good links, and there is also a link to the datasheet. The most useful information that I found, was in the forum at banggood from Ype Brada.This includes a detailed list of all (verified!) commands, a detailed description of the different ways how the sound files can be stored on the SD card, plus explanations and example code how to use the module without an additional library. My example code below is mostly based on this last source, but my setup uses information from all sources on the electrical connections, to avoid hum and/or buzzing sounds.

Components

Here is what you need:
  • Arduino Uno (or other)
  • DFPlayer module (cheap from AliExpress or eBay - but expect to wait 3-4 weeks, or from DFRobot)
  • microSD card
  • speaker 
  • one diode 1N4001
  • two 1kOhm resistors
  • two or three capacitors 30-470uF
  • two or three capacitors 0.04-0.1uF
  • 7805 voltage regulator
  • 6 AA batteries (I use rechargeable ones, to get 6x1.2V=7.2V)
  • PAM8403 2x3W amp (only required if you want to drive stereo speakers)

I tried three different microSD cards and all worked for me: two no-name cards (128MB for $0.90 and 1GB for $1.80) and a 4GB card from Kingston. All of these worked out-of-the-box, and also when formatted to FAT16 or FAT32. The 128MB card gives plenty of storage for my applications (approx. 60 minutes for mp3 files - this is much more than all R2-D2 and MSE-6 sounds that I could find on the web), and it is cheap.

Circuit

The most critical aspect is to get the player running without
producing hum or buzzing sounds. From other comments, it seems to be essential to decouple the power supplies of the Arduino and the DFPlayer, and to slightly reduce the voltage for the latter from 5V (although the data sheet specifies a range of 3.3-5.0V, it also quotes a typical value of 4.2V which seems to work better). To operate my circuit with a single set of batteries, I decided on the following solution:

I am operating the Arduino from 6 rechargeable NiMH AA batteries (6x12.V = 7.2V) through the Vin pin and add a 7805 voltage regulator to provide power for the DFPlayer and the PAM84503 2x3W amp (the amp is not required, when operating a single speaker, which can be powered directly by the DFPlayer). Most capacitors in this circuit are not necessarily required - I would only make sure to have a larger one in the front (33-470uF) and keep the 0.1uF at the output of the 7805 voltage regulator. The TX/RX pins of the module are connected to the RX/TX of the Arduino via serial 1k resistors.
The test setup on the breadboard looks a little chaotic - but it works!
And it looks much better on a PCB.

Modes of Operation

The DFPlayer mini has three modes in which mp3 files can be played:
  • mode #1:
    The files are stored in the root directory of the SD card. The file names do not matter. Files are accessed based on the number corresponding to the order in which they were written to the card. This sounds weird - I agree. I would only use this if I had a small number of files, and the files are not likely to change.
  • mode #2:
    Files are stored in folders, numbered 01-99, with filenames 001-255.mp3 or 001-255.wav, so you can store up to 99x255=25245 files. The files are accessed based on folder and file number.
  • mode #3:
    Up to 2999 files are stored in the directory "mp3" with four-digit filenames 0001.mp3-2999.mp3
The following example uses mode #2, which seems to be the most flexible one for my purposes, as it allows to organize the mp3 files in different folders.
Although there exists a dedicated library DFPlayer_Mini_mp3.h, this is not really needed. One probably improves the performance (storage, speed) and gains a deeper understanding by using standalone code (which is only a single subroutine dfpExecute() at the end of my example).
The general command structure consists of 10 bytes of which five are fixed, two are a checksum, and three specify the action (one is the command and two are parameters)
byte    function         value
(0)     start byte       0x7E
(1)     version info     0xFF
(2)     number of bytes  0x06
(3)     command          0x..  <- the command specifies by the user
(4)     command feedback 0x00  (if no feedback is required)
(5)     parameter 1 [DH] 0x..  <- 1st parameter (high-byte) specified by user
(6)     parameter 2 [DL] 0x..  <- 2nd parameter (low-byte) specified by user
(7)     checksum high    0x..  <- calculation is given below
(8)     checksum low     0x..  <- calculation is given below
(9)     end command      0xEF
The checksum is computed inside "dfpExecute()) as
checksum = - ( byte(1)+byte(2)+byte(3)+byte(4)+byte(5)+byte(6) )
and byte(7) and byte(8) are obtained as
checksumHigh = highByte(checksum)
checksumLow = lowByte(checksum) 
In mode #2, the command to play a single file is byte(3)=0x0F, byte(5) is the folder number (01-99), and byte(6) is the track number (01-255). So, playing file iFile in folder iFolder, is done by: dfpExecute(0x0F,iFolder,iFile).
One can check if a file is currently playing, by sending the busy signal (pin 16 of the module) to a digital input of the Arduino, which is LOW while a file is playing, and HIGH if not.
I read somewhere two recommendations, to wait at least five seconds between powering the player on and off, and to wait at least 20ms between subsequent commands. This should not cause any problems in typical operation.

Example Code 

For this example you should use a microSD card with a folder "01" that contains a few mp3 files (named 001.mp3, 002.mp3, 003.mp3, ...). The number of files is specified in the loop() in variable "nfiles". The example cycles through all files (playing the next file when the BUSY pin is HIGH, after a short delay), and starts again after the last file was played (with an additional delay of 4 seconds).
The DFPLayer's BUSY pin signals when a mp3 file is currently playing (BUSY == LOW) or if not (BUSY == HIGH). However, as pointed out in the comments below, it takes the busy pin a little time (<200ms) to become LOW after the mp3 file started playing. So, make sure to wait a little before checking the BUSY pin.
 //  
 //  --- example code for using the DFPlayer module ---  
 //  
 // Notice:  
 // All of the information/code here is largely taken from a posting  
 // by user Yerke in the forum at:  
 //  http://forum.banggood.com/forum-topic-59997.html  
 //  
 // This is example code for using DFPlayer in mode #2 (microSD card   
 // with directories 01-99, with filenames 001.mp3-255.mp3)  
 // In this example we assume three files (001.mp3, 002.mp3, 003.mp3  
 // in directory "01" on the SD card.  
 //  
 // This example shows how to  
 // - init DFPlayer  
 // - set the volume  
 // - check the "busy" pin of the DFPlayer  
 // - repeatedly play three MP3 sound files with names 001.mp3, 002.mp3, 003.mp3  
 //  which are stored in directory "01" on the SDcard.  
 //  
 // **************************************************  
 // Very important:  
 // In many setups, the DFPlayer produces noise.
 // To fix this, one should do two things   
 // - The DFPlayer prefers voltages below 5V.  
 //   For me it worked, by connecting it in series with a 1N4001 diode to 5V.  
 // - One should also use serial 1K resistors to connect its TX/RX pins to   
 //   the RX/TX pins of the Arduino  
 //   
 // Connect:  
 // - DFPlayer TX (pin 3) to Arduino pin 10 via a 1k resistor  
 // - DFPlayer RX (pin 2) to Arduino pin 11 via a 1k resistor  
 // - DFPlayer Busy (pin 16) to Arduino pin 12  
 // - DFPlayer speaker output (pins 6,8) to a speaker  
 // - DFPlayer VCC (pin 1) to 5V through a 1N4001 diode  
 // - DFPlayer GND (pin 7 or 10) to GND of the power supply and to Arduino GND  
 // **************************************************  
 //  
 // Wait at least 5 seconds before powering down/up the DFPlayer  
 //  

 const byte pinDfpRX = 10;  
 const byte pinDfpTX = 11;  
 const byte pinDfpBusy = 12;  
 const byte dfpVolume = 0x11; // set volume of DFPLayer - in range: 0x00-0x30 - default=0x30  
 
 #include "SoftwareSerial.h"  
 SoftwareSerial mySerial(pinDfpRX, pinDfpTX); // RX, TX  

 void setup () {  
  Serial.begin(9600);       // for printout  
  mySerial.begin(9600);      // for communication with DFPlayer   
  pinMode(pinDfpBusy, INPUT);   // init Busy pin from DFPlayer (lo: file is playing / hi: no file playing)  
  dfpExecute(0x3F, 0x00, 0x00);  // Send request for initialization parameters  
  while (mySerial.available()<10) // Wait until initialization parameters are received (10 bytes)  
  delay(30);            // have >20ms delays between commands  
  dfpExecute(0x06,0x00,dfpVolume); // set volume DL=0x00-0x30, default=0x30  
  delay(30);            // have >20ms delays between commands  
 }  

 void loop () {  
  const byte nfiles = 3;     // number of mp3 files on SD card  
  static byte ifile = 1;      // number of file played next  
  if (digitalRead(pinDfpBusy) == HIGH) {    // if no mp3 is playing -> play next file  
   delay(600);  
   Serial.print("now playing file No: ");  
   Serial.println(ifile);  
   dfpExecute(0x0F,0x01,ifile); // play (0x0F) file [ifile] from folder "01"  
   delay(200);          // wait a little for the busy line to become LOW
   ifile++;  
   if (ifile > nfiles) {  
    ifile = 1;  
    delay(4000);        // add a little delay before repeating the loop  
   }  
  }  
 }  

 // --- Excecute the DFPlayer command with two parameters (folder and file numbers)
 void dfpExecute(byte CMD, byte Par1, byte Par2)  
 {   
  # define Start_Byte   0x7E  
  # define Version_Byte  0xFF  
  # define Command_Length 0x06  
  # define Acknowledge  0x00   
  # define End_Byte    0xEF  
  // Calculate the checksum (2 bytes)  
  uint16_t checksum = -(Version_Byte + Command_Length + CMD + Acknowledge + Par1 + Par2);  
  // Build the command line  
  uint8_t Command_line[10] = { Start_Byte, Version_Byte, Command_Length, CMD, Acknowledge,  
         Par1, Par2, highByte(checksum), lowByte(checksum), End_Byte};  
  // Send the command line to DFPlayer  
  for (byte i=0; i<10; i++) mySerial.write( Command_line[i]);  
 }  
For further projects, just copy and paste the function "dfpExecute" into your Arduino sketch, and you can use the DFPlayer without any additional library. The functionality from this example (play a specified file from a specified folder, and check the BUSY pin if it is still playing) should be sufficient for many Arduino projects.
If you want to use additional functionality, you should check the posting by Ype Brada and maybe get additional information from the data sheet

Additional Comments

Formatting

After using the DFPLayer mini in various projects, I can confirm that the module works well with audio files in different formats. So far I had success with .mp3 and with .wav files, in stereo and in mono, and with different sampling rates like 15kHz, 22.05kHz, 44.1kHz, and 48kHz. I stored these on 128MB micro SD cards as they arrived, without any formatting. In other words: You can use a store-bought micro SD card and copy all your existing files from your collection on it, without worrying about (re-)formatting the card and/or the sound files. I only recommend to normalize the sound files, so they play at maximum loudness.

Amplifier

The circuit shown above uses an additional 3W stereo amplifier (PAM8403). In my recent projects, however, I found that this is not really needed and I just used the integrated amp. This gives a very reasonable loudness which, in particular with a slightly larger speaker (3"-4"), should be sufficient for most indoor purposes (I never set it to max volume). Of course, this amp is only mono - but that's o.k. for my robots and my HAL 9000 replica.

Arduino Serial

My example code above uses the SoftwareSerial library. But the Arduino Mega has four hardware serial ports. Using a hardware serial saves the memory required by the SoftwareSerial library. When using Serial3 (with TX3, RX3 pins), one only needs to replace the three occurences of "mySerial" by "Serial3" (and to remove the two lines with "SoftwareSerial".)

Some Trouble

The code above always worked for me when using Arduino Unos or Megas. However, recently, I saw a problem when using an Arduino Pro Mini - the same problem that is mentioned in one of the comments below: The code gets stuck at this statement:
while (mySerial.available()<10) // Wait until initialization parameters are received (10 bytes) 
It does not do any harm to simply remove this statement (or maybe just comment it out).

Noise Issues

Many people are reporting noise issues. To avoid these, it seems that the following steps are essential
  • Do not operate the DFPlayer at 5V. Either use a separate power supply - or use the diode (as in the circuit above).
  • Insert resistors (e.g. 1k Ohm) in the TX/RX lines (as in the circuit above)
  • The DFPlayer has two GND pins (pins #7 and #10). These should always be connected by a short wire that goes directly from one to the other (it seems that I always did that in my circuits, but I did not indicate this in the circuit above). 

My Projects with the DFPlayer Mini

The setup and the basic code detailed above were successfully used in the following movie props that I built:
  • Star Wars, Mouse droid MSE-6 
  • Star Wars astromech droids R3-B9 and X7-OB, imperial droid H015
  • In my Flux Capacitor ("Back to the Future") the DFPlayer is used to play electric hum and buzz sounds 
  • In the Time Circuits ("Back to the Future"), the DFPlayer, plays the DFTM sounds for the keypad, the turn-on, turn-off, etc. sound clips, and a few songs from the movies.
  • HAL 9000 replica ("2001 - A Space Odyssey") - DFPLayer plays all of HAL's clips
  • In the planning phase: GERTY 3000 replica ("Moon")
If you want to use the DFPlayer to play sound clips from movies, I have a tutorial on how to rip the audio track from a DVD here.