Android Question Best use of BEEPER. Delete Relase or put a SLEEP?

Status
Not open for further replies.

netsistemas

Active Member
Licensed User
Longtime User
Is correct definie a public beeper and use this in all code?

when you do this:
B4X:
Dim B As Beeper
            b.Initialize(1500, 650) '
            b.Beep
            'what to do?   .  sleep or delete b.relase? '
            Sleep (200)
            B.Release


the b.release cancel the sound. The solution is delete b.relaase, but, the B var are not relase?
may be dangerous create a lot of Beebper var and not to do release?
 

William Lancee

Well-Known Member
Licensed User
Longtime User
You can do what you want, just sleep for slightly longer then the length of the beep.
In this case Sleep(1501)

Generally It isn't 'dangerous' to not release resources. However if you create them in a loop (say 10000 steps), there might be a memory overflow.

Why don't you use one Global Beeper for all your needs. You won't have to worry about Sleep() and B.Release, there will only be one resource, which will be released when the App is killed by the OS.
 
Upvote 0

William Lancee

Well-Known Member
Licensed User
Longtime User
I was thinking a set of different beepers with different frequencies and durations. However their number would still be relatively small and each could easily be initialized once.
[Curiosity makes me ask why not initialize multiple times, like we do with Stringbuilder? ...still learning]
 
Upvote 0

Amateurtje

Member
Licensed User
Longtime User
any chance of getting a good code example. On all threads for the beeper, there are a lot of suggestions, but wouldn't it be nice to have a working example.. I understand that coding is a kind of goal for you but for us it is a tool to mkae the tools we need to have working........
support and code examples are the most welcome for that..

Some people even do not mind to pay a little for that, even while the software is free nowadays......I made this suggestion more times...
 
Upvote 0

netsistemas

Active Member
Licensed User
Longtime User
i don't know exactly what is your comment (my english is not very good,... best to say: is very bud).
In the first post are the code.
that is:

B4X:
Dim B As Beeper
            b.Initialize(150, 650) '300 milliseconds, 500 hz
            b.Beep
            Sleep (150)
            B.Release

or create a PUBLIC VAR ( Dim B As Beeper) in a process_globals and only do this:


B4X:
    b.Initialize(250, 300) '300 milliseconds, 500 hz
            b.Beep
 
Upvote 0

Amateurtje

Member
Licensed User
Longtime User
For every small remark, starting a new thread... Isn't that an overflow on forum threads? For searching of the topic it does not become easier.. And a topic/problem is often half solved and then people start referring to the existing topics which are always only half of the answer... Most forums like to keep it compact and more depth...
 
Upvote 0
Status
Not open for further replies.
Top