Audio Visualizer Library (Record and Play)

Douglas Farias

Expert
Licensed User
Longtime User
Hello everyone.

I am building a project with Arduino and Android, and I have some difficulties with audios.

In this project I need to control an engine in Arduino which has the amplitude from 0 to 255 (engine power).

In the app I want to offer two options, one of them is to HEAR the microphone audio and turn it into vibration, being 0 = no music and 255 the highest beat.

The same I need to do for local music (MP3), open the media player play the music, 0 = no sound, and 255 the highest beat.
I believe the stevel05 library already does this
https://www.b4x.com/android/forum/threads/audio-visualizer.41850/
but I don't know how to convert to 0 - 255!

I don't need anything complicated like graphics etc ...
I only need one sub returning me values from 0 to 255, where 0 is no song and 255 is the peak (DB) of the song.

I need a Sub that gets these values every millisecond and from this sub I can control the engine.

In the microphone option, I need the audio to be saved, because the user can listen later and convert to beats (0 to 255).

You can see an example here.

This is a female vibrator, it has the option of listening to a song and turning it into vibration, and it also has the option of recording your voice, and as the noise of the recording makes it vibrate stronger.

This is exactly what I need.

Payment is via PAYPAL.

It could be a library, a class or just inline Java code, I don't care about that. I only care that it works on Android 2.3+ and does not crash.



Here is a simple image example what i need.
sample.jpg

ps: i dont need the graphics, it is only to show the values 0 to 255 on a music playing.



This is an example of code that I need, I need something like this code below.
B4X:
Sub Process_Globals
End Sub

Sub Globals
    Private audio As AudioC
End Sub

Sub Activity_Create(FirstTime As Boolean)
   
   
    'INITIALIZE
    audio.Initialize("audio")

    'HERE IS THE OPTIONS USING MICROPHONE------------------------------

    'START RECORD (THIS WILL FIRE THE audioc_sound SUB, and show values under 0 to 255)
    audio.Start_RecordAudio(File.DirInternalCache,"filename.wav")
   
    'A SIMPLE EVENT TO KNOW IF IT IS RECORDING AUDIO
    Log(audio.is_Recording)
       
    'THIS WILL STOP THE RECORD AND SAVE THE WAV OR MP3 FILE.
    audio.Stop_RecordAudio
   
   
   
   
   
    'HERE THE OTIONS USING MEDIA PLAYER-------------------------------
   
    'START PLAY MUSIC (THIS WILL FIRE THE audioc_sound SUB, and show values under 0 to 255)
    audio.Play_Music(File.DirInternalCache,"music.mp3") 'MP3 OR WAV
   
    'A SIMPLE EVENT TO KNOW IF IT IS PLAYING MUSIC
    Log(audio.is_Playing)
   
    'A OPTION TO PAUSE PLAYING MUSIC
    Log(audio.Pause_Music)
   
    'A OPTION TO RESUME PAUSED MUSIC
    Log(audio.Resume_Music)
   
    'A OPTION TO STOP A PLAYING MUSIC
    Log(audio.Stop_Music)
   
   
   
End Sub

Sub Activity_Resume
End Sub

Sub Activity_Pause (UserClosed As Boolean)
    If audio.is_Recording Then audio.Stop_RecordAudio
    If audio.is_Playing Then audio.Stop_Music
End Sub



Sub audio_sound(level As Int) 'THIS LOG A VALUE UNDER (0 TO 255), 0 = NO SOUND OR MINIMAL SOUND AND 255 = MAX AUDIO
    Log(level) 'HERE I WILL MAKE THE ENGINE VIBRATE
End Sub



Pls if you want to make this, tell me the price VIA PM.

Thank you
 

Douglas Farias

Expert
Licensed User
Longtime User
I forgot to comment, I can pay 100$ for this example.
 

Rafael Grossi

Member
Licensed User
Oi Douglas

Não sei se é exatamente o que você quer, mas tem alguns exemplos no fórum de medidor de intensidade sonora em decibéis.
Nos exemplos, você mede a intensidade sonora em uma escala do próprio app, em uma unidade arbitrária, e então pode calibrar o resultado dessa unidade com um decibelímetro profissional, e exibir em dB.

No seu caso, acho que você pode fazer alguns testes para calibrar seu app da maneira que desejar. Por exemplo, você coloca o aparelho no ambiente silencioso e vê qual a intensidade que ele vai dar. Esse será o seu zero. Em seguida coloca num ambiente bastante barulhento, sendo este o seu limite superior de intensidade, e vê qual intensidade o app irá medir. Esse será o seu 255. Entenda que normalmente não conseguimos silêncio absoluto. Existem salas de pesquisa nas quais tentam deixar silêncio absoluto, onde é possível escutar o próprio batimento cardíaco. Por isso mesmo em uma sala muito silenciosa, você terá uma intensidade razoável, traduzida em pressão sonora percebida pelo microfone.

Como a escala de intensidade sonora é infinita, você deverá determinar o seu zero e seu 255 de acordo com intensidades sonoras plausíveis para o seu projeto.
Tendo a intensidade mínima e máxima medida pelo app, em escala arbitrária, você fará uma regra de três para traduzir a intensidade sonora na faixa de 0 a 255.

Links:
https://www.b4x.com/android/forum/t...time-display-of-sound-level-db.91313/#content
https://www.b4x.com/android/forum/threads/badly-needed-microphone-library.11731/page-2#post-90058

Não sei se era bem isso, mas espero que ajude.
Abraço!
 

Douglas Farias

Expert
Licensed User
Longtime User
Olá @Rafael Grossi.
Sim é exatamente o que preciso, porém infelizmente no momento estou correndo atrás de outras partes desse projeto e estou sem o tempo para faze-lo.
Você já fez algo do tipo? a parte do microfone eu já tenho um caminho, um membro do grupo já me mandou um exemplo, porém estamos testando ainda a questão da sensibilidade.


Sobre o MP3 Player, ninguém ainda me mandou algum exemplo ainda.
Eu continuo na busca.
Penso em usar o media player nativo do B4X.
 

Douglas Farias

Expert
Licensed User
Longtime User
I increased the budget for this library by + $50, now it's $150

@sorex already sent me an example of the microphone, we are testing the issue of sensitivity etc ...
The part of MP3 nobody sent me examples yet. (still open for solutions)
 

Douglas Farias

Expert
Licensed User
Longtime User
Today I received a complete and functional example made by @Brandsum
working with both the mp3 player and the microphone, it also added a sensitivity control, which was great.
Then I declare the work finished.
Thanks to everyone who got in touch and somehow tried to help me.
 
Top