B4A Class [B4X] [XUI] Audio Wave

jtare

Active Member
Licensed User
For a while now I've been looking for an animation to represent some sort of ai talking but couldn't find anything beside videos and gifs. I wanted something that can be usable in an app, so I came across with this project on github which is close enough for what I wanted but it was written in javascript which I know very little, but I managed to translate it to b4j and later to a b4x class.

NOTE: I only translated the one in the left (no colors). It shouldn't be that hard to add the one in the right, I will try in the future.


How to use it:
(Add the siriview.bas class into the project)
B4X:
Sub Globals
    Private canvas1 As B4XCanvas
    Private lblC As Label
End Sub

Sub Activity_Create(FirstTime As Boolean)
    Activity.Color = Colors.White
    lblC.Initialize("")
    Activity.AddView(lblC,0,80%y,100%x,100%y-80%y - 20dip)
    canvas1.Initialize(lblC)
    Dim siriV As siriview
    siriV.Initialize(5) 'the refresh rate depends on the device, on pc 20 is fine but on android, 5 seems fine
    siriV.SiriWaveFunc(canvas1,lblC.Width, lblC.Height,1,1,0.12,6,0.005, 0.05,46,46,46,True)
    Sleep(5000)
    siriV.siriwave_setAmplitude(0.01)
    Sleep(1000)
    siriV.siriwave_setAmplitude(0.8)
End Sub
You can also set amplitud, set speed, start and stop.

Only tested in b4a and b4j.

As a first attempt it was close enough, what I'm looking for is something like this. (I just realize you need a pinterest account to see it)

EDIT: Performance is not very good, I'm looking for a solution.
 

Attachments

Last edited:

klaus

Expert
Licensed User
I had a look at your project.
I would suggest you to make an XUI CustomView out of it, which means one unique SiriView.bas file valid for all three products.
You could then add the SiriView in the Designer like any other view.
 

klaus

Expert
Licensed User

Star-Dust

Expert
Licensed User
Another one: Don't call it "Siri" as the name is owned by Apple :cool:
Better if you remove the word Apple and ios from your post because they are owned by Apple inc. (C)

All trademarks used in this message are owned by Apple inc. (C) :p
 
Last edited:

Star-Dust

Expert
Licensed User
i wanted to try the Class but siriwave is missing. where can i get it please?
In the first post there is the .bas file
 

Star-Dust

Expert
Licensed User
Have you checked the XUI library?
 

Attachments

Top