Hi, Im trying to play sequential wav files. Ive tried Player and sound, both seem to have the same issue which is me not understanding how they work.
When I run the code, only one wave file plays or i can hear which is the last file. Im assuming there running through all files quickly, that's a guess.
I tried using a procedure to play the file, its called every time I want to play the file, but only hear the last file.
Hi, thanks, here are two screen shots of the code. As mentioned I only hear 1 WAV file. reading some posts it seems maybe pre-loading the 19 WAV files might solve the problem. Will try that next
Is 'PlayTune' an extension? It doesn't look right in your Blocks - why would the parameter 'x' be set to 'blank text'? Also, you are using text Blocks for your .wav files but you can instead use App Inventor's media Blocks. Another thing to consider is that .wav files are much bigger than .mp3 - although .wav arguably has better quality, that isn't noticeable on your average Smartphone.
EDIT: It has been pointed out to me that 'PlayTune' is a procedure. Tip: Give every component a meaningful name - but always retain the component type name e.g. Label_PickedValue, Button_CalcTotal, procedure_PlayTune
The playing of your 'tunes' run into each other - your code isn't waiting for the first to finish before calling the next, so that is why only the last is actually heard. Are they 'long' (a tune or piece of music) or 'short' (a sound effect). Use the Player component for 'long' and Sound component for 'short'.
If the files are to be played in succession, a great solution is to merge them into one file - it's easy to do that with an editor such as Audacity:
... which you can also use to convert from .wav to .mp3.
Hi thanks for the response. I originally used sound as the wav files are a few seconds. In the sound library I'm not sure what function tells me the wav file is finished.
...you will need to verify the length of each sound, put those times, in milliseconds, in a Block List and when a sound is played, enable a Clock timer for it's related time in the Block List - or use the Player which does know when the sound has finished.
However, if the sounds are short as you say, each sound can be played over the previous, just like a piano:
Use Player, not Sound.
Player have a event When Player.Completed (not sure if this exact name). in this event, play next wav file. as for which is next, use a list to store wave files and a counter to indicate which one is playing.
Im having a hard time picturing this logic in my head lol. With the attached block image, even though Im checking to see if the play tune has completed, want the code just continue running through all selected wav files untill the last wav file has completed.
Which means the order of the wav files will be differant all the time.
I need to implement a que where each wav file is played in order. eg(wave3.wav, then wave9.wav, then wave2.wav) and so on.
Having a brain strain here lol
Hi Chris, basically what happens is the user says a sentence which is translated to text. I then calculate how many words are in the sentence.
There is 1 wave file played per word, so if I say "Hello World The Sun is out" there are 6 words.
I then call a random wave file between 1 - 19 for each word.
Then i wait for the next sentence to be spoken and do it all again.
Hope that helps understand what I'm trying to accomplish.
Each wave file is a few seconds long.
Hi all, thanks for all your help today. I finally found out why Im getting the 701 unable to load error when randomly selecting from 1 to 19 audio files.
Any files over 9 will flag that error, eg (wave3.wav or wave3.mp3) are ok, under 10. if the file chosen was (wave10.wav or wave10.mp3) the error appears and no sound.
Is there a limit to how many audio files you can load. Please see test code. I had each audio file name printed to a label.
Thanks will check.
Attached is the final blocks that work for sequential playing of files incase someone
else is having a brain freeze like i did lol.
Once again thanks to everyone that helped.