No Soundpool when using touch subs

AntonBrz

Member
Licensed User
Longtime User
I've been using B4A a month now and set up wav's to play using soundpool a hundred times. Ive never used a touch panel to get the X and Y before, always used clicks and buttons. I've tested touch panels different ways for two days, always coming up silent on the emulator or my Android tablet. Audio is checked in the libraries in the usual way. My sound is up and soundpool works in other programs. The Dims and initializing are correct. Even reducing the touch test to a bare minimum, there is no audible sound. The same dims and initializing work in other programs. Adding a button and subroutine to trigger a wav can't make a peep. The wavs used are short and work in other programs. They exist in this program's files and no errors show during compilation, or running. What simple thing am I missing? I see programs where touching the screen makes sounds all the time.The code below is all there is in the test after properly setting up the variables, initializing sound pool and loading the wav's correctly.

B4X:
Sub Panel1_Touch (Action As Int, X As Float, Y As Float)

' The panel and bitmap I loaded as a background are showing fine now
' I can get the X and Y fine if I put code to check that here   
' if I put a sp.play command here no sound is heard. 

End Sub
Sub Panel1_Click

sp.Play(LoadID2, 1, 1, 1, 2, 1)
' I also tried it gamesoundID2 = sp.Play(LoadID2, 1, 1, 1, 2, 1)
' again I hear nothing. Yes the volume is up.
End Sub
Sub Exit_but_Click
   gameoundID1 =  sp.Play(LoadID1, 1, 1, 1, 0, 1)  ' nothing is heard
   'or sp.play(LoadID1,1,1,1,0,1) ...again nothing is audible.
   MakeExit =2   ' a  var I made up 'anticipating creating a turn off the program routine
End Sub


I set up buttons to make a click or beep noise all the time, it always works before.
I only have this problem when I create a panel with the touch response. So what gives? What's obvious to you that I don't understand?
 

Quillok

Member
Licensed User
Longtime User
I'm not sure If I understand the problem,
but I think it should work when you use

B4X:
Sub Panel1_Touch (Action As Int, X As Float, Y As Float)

If Action = Activity.ACTION_DOWN then
     sp.play
end if

End Sub

I think its because the event fires many many times if you touch the panel and when you use activity.Action_Down it fires only once the panel is start touching. then the program has the time to play your sound.
 
Upvote 0

AntonBrz

Member
Licensed User
Longtime User
Aha, a lead....

B4X:
Sub Panel1_Touch (Action As Int, X As Float, Y As Float)

If Action = Activity.ACTION_DOWN then
     sp.play
end if

End Sub

The question is why aren't any sounds playing when I use the touch subs. Sounds like you may have an answer. I'll try this then, thanks.
 
Upvote 0

AntonBrz

Member
Licensed User
Longtime User
Sound plays, kind of...

An interesting thing is when I went into designer and made an already existing panel in a different program have touch XY activity., then put the above DOWN activity into the touch routine,a sound played beautifully. So now I have to really examine the test panel program to find out why that's different than the program with the working sound. Because when I tried putting that Activity-down code into the test, it wasn't audible. The program with the sound working in the touch routine already had sounds working on buttons. ---click.wav and so on.
 
Upvote 0

AntonBrz

Member
Licensed User
Longtime User
Sound Pool in touch loop SOLVED

:signOops:
I compared working wav files to the ones in the test, and... the ones in the test I'd recently purchased. They played well in my sound editors, but putting them back into GoldWave and Media Workshop audio and examining their properties, I discovered they were sampled at some insanely high rate compared to wav files which are audible in B4A programs. I re-sampled them at only 8000, which seems to be fine for voice, and now the Touch loop and sound are working fine together. Thanks to all for your help.
 
Upvote 0

AntonBrz

Member
Licensed User
Longtime User
Note that you should not use bold text for the complete post. It is more difficult to read.

Thank you. Erel is a name I respect. My laptop screen has to be set at 1440x900 pixels to see the bottom of the B4A emulator in portrait mode, unless I set the emulator to be tiny. At that resolution of the laptop screen, from my eye's position four feet from the monitor, the default size text in all the posts look like tiny grains, nearly dots. I should think default text should be much larger, and bold. How are you reading them so easily?

I entirely value your opinion, since your involvement with b4A us awesome, and I mean no disrespect. Also I know my opinion has no value at all.
 
Upvote 0

AntonBrz

Member
Licensed User
Longtime User
CNTL and mouse wheel

Thanks. As when I've written to someone in Federal government or some top scientist, when they take the time to respond, I'm humbled and honored at the same time. I respect a good programmer. I knew how to enlarge the on screen image, and have to do that but wish I didn't. Well I use CNTL ++ to make it larger. And I will read best practices. I assumed it was about not using racial attacks, posts trying to sell things, or posting sexual things or off topic rambles. I've been in one programmer's forum or another since the 70's so I know enough not to do those things. I didn't realize there would be restrictions about formatting as well. But thank you for directing me to read it.

Anton
 
Upvote 0

AntonBrz

Member
Licensed User
Longtime User
On Post # 2

If you don't want to read the answer (post #2), don't ask the question ;)

I apologize for not commenting. I did read the answer, I just didn't understand how it would let me play sounds in a touch event. I'm not sure any of this was relevant and i apologize, because I found out the wav files I was trying to use, which had been newly purchased, were highly sampled and seem incompatible. As soon as I processed them way down, too 8000 samples, they play just fine with using sound-pool inside touch subs, at least using the 'If Activity...is touch down' code, in a post above. Thank you very much for taking the time to give me the answer. As it turned out, I was only using the wrong kind of wav file.

In the future I'll try to comment on each response.Even if it embarrasses me to admit I don't completely understand it.
 
Upvote 0

Informatix

Expert
Licensed User
Longtime User
I apologize for not commenting. I did read the answer, I just didn't understand how it would let me play sounds in a touch event. I'm not sure any of this was relevant and i apologize, because I found out the wav files I was trying to use, which had been newly purchased, were highly sampled and seem incompatible. As soon as I processed them way down, too 8000 samples, they play just fine with using sound-pool inside touch subs, at least using the 'If Activity...is touch down' code, in a post above. Thank you very much for taking the time to give me the answer. As it turned out, I was only using the wrong kind of wav file.

In the future I'll try to comment on each response.Even if it embarrasses me to admit I don't completely understand it.

The code that you posted here (post #1) can't play sounds, whatever sound format you use (the click event cannot be fired if you declare a touch handler; when you touch the screen, only one event is generated (the down event); if an handler traps it and doesn't propagate it, the other listeners can't see it). So the first thing to do was to change your code.
Anyway, I should have warned you about the WAV files. This format is not recommended for SoundPool. You should use only Ogg and Mp3 files with it.
 
Last edited:
Upvote 0

Informatix

Expert
Licensed User
Longtime User
Thanks. As when I've written to someone in Federal government or some top scientist, when they take the time to respond, I'm humbled and honored at the same time. I respect a good programmer. I knew how to enlarge the on screen image, and have to do that but wish I didn't. Well I use CNTL ++ to make it larger. And I will read best practices. I assumed it was about not using racial attacks, posts trying to sell things, or posting sexual things or off topic rambles. I've been in one programmer's forum or another since the 70's so I know enough not to do those things. I didn't realize there would be restrictions about formatting as well. But thank you for directing me to read it.

Anton

:sign0089:
Personnaly, I don't care if you use bold characters, but as a general advice, you should respect the forum rules, whatever they may be. Each forum has its own rules and it's surprising that you don't know that, with all your experience... ;)
 
Upvote 0

AntonBrz

Member
Licensed User
Longtime User
Anyway, I should have warned you about the WAV files. This format is not recommended for SoundPool. You should use only Ogg and Mp3 files with it.

Hi, just read this. At three AM here I started changing all my wav files to 8000 hz samples so they'd play. Now its around 4 AM when I found this. I'm going back and change them all to ogg files. Thanks.

Anton
 
Upvote 0

AntonBrz

Member
Licensed User
Longtime User
apology

:sign0089:
Personnaly, I don't care if you use bold characters, but as a general advice, you should respect the forum rules, whatever they may be. Each forum has its own rules and it's surprising that you don't know that, with all your experience... ;)

Sorry. I might have experience but am at fault for never have patience with reading documents. As an artist who has published several books and sold a thousand original artworks a year, it takes every minute I can grab to get the slightest thing done. Early on I scanned several forum rules and got you that you aren't supposed to rant or advertise or foster hate towards other groups etc. and just went with that. I'll be careful to read the entire standards for this forum, as B4A is an excellent IDE and compiler, really great how much thought went into it. I anticipate it will change and grow with new technology in the future and be useful for a very long time on devices yet to come, and so it's worth mastering. I'm a big believer in the future and a lot of my portfolio is in NTEK,. Thanks again & my apologies.
 
Upvote 0
Top