The attached project wraps part of this Github project (I only wanted to wrap the voice visualizer part of the project). It actually records the sound too and will store the yourfilename.wav file in the root folder of your device. See the attached sample project where I have added a date/time stamp to the filename.
You can amongst others set the colors of the bars and if the bars should extend from the top or bottom of the view
Posting the following:
1. B4A library files - copy them to your additional library folder
2. B4A demo project
3. Java source code - you will have to create a folder named libs on the same folder level as the src folder and then copy android-support-v4.jar and simplesound-0.1.jar into this folder in order to compile the Java project with Eclipse / SLC / etc. (simplesound-0.1.jar is included in the attached zip file that contains the B4A library files)
You will also need a recent version of android-support-v4.jar in your additional library folder. You can download it from HERE.
Take note of the permissions added to the Manifest in case you start a new B4A project.
BARS EXTENDING FROM THE TOP OF THE VIEW:
BARS EXTENDING FROM THE BOTTOM OF THE VIEW:
Sample Code:
The library:
AndroidRecording
Author: Github: Julia Zudikova, Wrapped by: Johan Schoeman
Version: 1
VisualizerView
Fields:
You can amongst others set the colors of the bars and if the bars should extend from the top or bottom of the view
Posting the following:
1. B4A library files - copy them to your additional library folder
2. B4A demo project
3. Java source code - you will have to create a folder named libs on the same folder level as the src folder and then copy android-support-v4.jar and simplesound-0.1.jar into this folder in order to compile the Java project with Eclipse / SLC / etc. (simplesound-0.1.jar is included in the attached zip file that contains the B4A library files)
You will also need a recent version of android-support-v4.jar in your additional library folder. You can download it from HERE.
Take note of the permissions added to the Manifest in case you start a new B4A project.
BARS EXTENDING FROM THE TOP OF THE VIEW:
BARS EXTENDING FROM THE BOTTOM OF THE VIEW:
Sample Code:
B4X:
#Region Project Attributes
#ApplicationLabel: b4aAndroidRecording
#VersionCode: 1
#VersionName:
'SupportedOrientations possible values: unspecified, landscape or portrait.
#SupportedOrientations: portrait
#CanInstallToExternalStorage: False
#End Region
#Region Activity Attributes
#FullScreen: False
#IncludeTitle: True
#End Region
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Private ar1 As VisualizerView
Private b1 As Button
End Sub
Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:
Activity.LoadLayout("main")
ar1.VisualizerColor = Colors.Yellow
ar1.VisualizerBarWidth = 2.0
ar1.DrawBarsFromTop = False
ar1.VisualizerDivisions = 2
DateTime.DateFormat = "yyMMddHHmmss"
ar1.RecordingFileName = "myRecording" & DateTime.Date(DateTime.Now) 'it will be stored as a .wav file
'set up all of the above before calling ar1.setupVisualizer
ar1.setupVisualizer
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
ar1.ReleaseResources
End Sub
Sub b1_Click
ar1.StartStopRecording
End Sub
The library:
AndroidRecording
Author: Github: Julia Zudikova, Wrapped by: Johan Schoeman
Version: 1
VisualizerView
Fields:
- ba As BA
- BringToFront
- DesignerCreateView (base As PanelWrapper, lw As LabelWrapper, props As Map)
- Initialize (EventName As String)
- Invalidate
- Invalidate2 (arg0 As Rect)
- Invalidate3 (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int)
- IsInitialized As Boolean
- ReleaseResources
- RemoveView
- RequestFocus As Boolean
- SendToBack
- SetBackgroundImage (arg0 As Bitmap)
- SetColorAnimated (arg0 As Int, arg1 As Int, arg2 As Int)
- SetLayout (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int)
- SetLayoutAnimated (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int, arg4 As Int)
- SetVisibleAnimated (arg0 As Int, arg1 As Boolean)
- StartStopRecording
- setupVisualizer
- Background As Drawable
- Color As Int [write only]
- DrawBarsFromTop As Boolean [write only]
Draw the bars from the top or bottom of the view
The default value false - Enabled As Boolean
- Height As Int
- Left As Int
- RecordingFileName As String [write only]
- Tag As Object
- Top As Int
- Visible As Boolean
- VisualizerBarWidth As Float [write only]
Set the width of the visualizer bars
The default value is 5.0f - VisualizerColor As Int [write only]
Set the color of the visualizer bars
The default color is Color.argb(200, 227, 69, 53) - VisualizerDivisions As Int [write only]
divisions - must be a power of 2 (i.e 2, 4, 8, etc). Controls how many lines to draw
The default value is 2 - Width As Int
Attachments
Last edited: