188bet服务官网You guys might have already come across some cool interesting prank projects made out of Arduino.I have recently built a similar kind which am going to call as Karaoke prank machine.The project turned out as expected and I would like to share the steps involved in building it with you guys.
PRANK IDEA:
Have you come across situation where you sing a song in public and it was not well received by the audience?Well that's the base idea of this project.In the place of audience our Arduino will provide feedback for people's song.In an essence this will let user to sing through a microphone and Arduino will boo at them with various critique dialogues of which ,few are very mean ( I added it on purpose :), the more mean it is, funnier the prank is).
WORKING OF KARAOKE PRANK MACHINE:
MATERIALS REQUIRED:
- Arduino Uno – 1
- Microphone module – 1
- SD card module
- SD card with preloaded files
- LM386 – 1
- (0.5W) 8 Ohms speaker – 1
- Resistors ( Values indicated in circuit diagram )
- Capacitors ( Values indicated in circuit diagram )
- Connecting wires ( As required )
SCHEMATIC DIAGRAM OF KARAOKE PRANK MACHINE:
CIRCUIT EXPLANATION:
Arduino Uno & SD card shield:The base part of this project comprises of Arduino Uno and Ethernet shield.The Ethernet shield was used to plug in the SD card and read it through Arduino.
SD card:The card is preloaded with the insulting speeches which will be played by Arduino.I have usedonline text to speech converterfor generating insulting speech with nice tone and modulation :).In order for Arduino to play these files it should be converted to Wav format (use this online Audio to wav converter) with following options enabled.
- Bit Resolution – 8
- Sampling rate – 11.5khz to 22khz
- Audio Channels – Mono
- Advanced options >> PCM format – PCM unsigned 8 bit
Here is all the dialogue files i have used in my project, download it here
Microphone module:The microphone module converts the user voice into digital signals with a fixed peak voltage.This module will serve our cause since we are not dealing with speech processing, we need to just count the number of peaks occurred within the period of time.This number of voltage peaks vary with each user based on their voice frequency and type of the song (fast or slow) they sing. By doing this we can eliminate the chance of same dialogues getting repeated for all the user.
LM386 Amplifier:
This is one of the basic amplifier circuit given in the LM386 datasheet.This circuit worked fine and met my needs for my project.
WORKING LOGIC:
The working starts with the Microphone module by taking the input audio signal from user.The module am using is only capable of converting incoming audio signal to digital.Whereas this digital signal will have same peak amplitude voltage rather than varied ones like analog signal.This module will suffice my project need since i'm not gonna perform speech processing with the input audio signal.Rather i will count the number of peak voltage occurrence while an user sings for a given period of time.It varies based on the frequency at which the user sings and their choice of song. It can be done by Sampling the output from the module with fixed time intervals using Arduino.
Since these counts of voltage peaks are distinct, i have used this criteria to differentiate users in my code.The below given diagram shows the snapshot of digital output received from the Microphone module ( for your reference).Arduino will sample the signal and keep the count of peak amplitudes encountered.This count will be used in our code for Arduino to decide which feedback Audio file to play.For example
Low count – No song
High count – Stop screaming
As mention in the circuit explanation Arduino can only play PCM coded audio files with the criteria ( 11.5khz to 22khz, 8 bit unsigned PCM and mono channel).Finally based on the number of peak values the corresponding audio file will be played.
TMRPCM Library:This is a special library which is capable of playing PCM coded audio file from SD card.This library will enable Arduino play the PCM signal using inbuilt PWM feature.Here is theGithub repository link for TMRPCM library.
CODE ALGORITHM:
- Initialize SD card readability, Analog pin and TMRPCM library
- Sample the incoming audio signal at regular intervals say 1ms (doesn't necessarily need to be in human speech frequency).
- The sampling process need to continue till the time you want user to sing the song, in this project i have let user to sing for about 30 seconds.
- Check the number of samples that is above or equal to peak voltage.
- Create several criteria with peak voltage values based on the number of audio files you want to include in this project.
- Once a certain criteria is met force Arduino to play your desired insulting speech audio file.
CODE:
#include// need to include the SD library #define SD_ChipSelectPin 4 //using digital pin 4 on arduino nano 328, can use other pins #include // also need to include this library...#include TMRpcm tmrpcm!unsigned long max_frequency!unsigned long listen_time!int sensorValue!char voice!void setup() { if (!SD.begin(SD_ChipSelectPin)) { // see if the card is present and can be initialized: Serial.println("SD fail");} max_frequency=listen_time=0!pinMode(9,OUTPUT)!digitalWrite(9,HIGH)!Serial.begin(9600)!tmrpcm.speakerPin = 9!} void loop() { if(listen_time<30000) { sensorValue = analogRead(A0)!listen_time++!if(sensorValue>1000) { max_frequency++!} delay(1)!} else { assessvoice()!while(1)!} } void assessvoice() { if(max_frequency<=300) voice='a'!if(max_frequency>300&&max_frequency<=2300) voice='b'!if(max_frequency>2300&&max_frequency<=4300) voice='c'!if(max_frequency>4300&&max_frequency<=6300) voice='d'!if(max_frequency>6300&&max_frequency<=8300) voice='e'!if(max_frequency>8300) voice='f'!feedback(voice)!} void feedback(char voice) { switch(voice) { case 'a': { tmrpcm.volume(5)!tmrpcm.play("7.WAV")!break!} case 'b': { tmrpcm.volume(5)!tmrpcm.play("8.WAV")!break!} case 'c': { tmrpcm.volume(5)!tmrpcm.play("9.WAV")!break!} case 'd': { tmrpcm.volume(5)!tmrpcm.play("10.WAV")!break!} case 'e': { tmrpcm.volume(5)!tmrpcm.play("11.WAV")!break!} case 'f': { tmrpcm.volume(5)!tmrpcm.play("12.WAV")!break!} default: return!} }
NOTE:
- Keeping the criteria range of max_frequency low will give you varied range in dialogue selection.
- I have only used 6 dialogues totally, you can increase this to your desired level.Increasing the dialogues will make this karaoke prank more effective.