Stopping a list of musical notes

Getting into LiveCode for iOS? Ask your questions here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
jessamy99
Posts: 103
Joined: Thu Oct 25, 2012 3:23 pm

Stopping a list of musical notes

Post by jessamy99 » Wed Jul 10, 2019 4:05 pm

Hi Team and everyone,

I am getting frustrated with such a tiny thing!
I am sure you will be able to solve this for me.

I am playing a series of notes in a repeat loop.
But I want to allow the user to stop the music if so desired.

The scripts I have been trying are these...

repeat while x< y
put line x of tmusic into tAudio

if the environment is mobile then
play (specialFolderPath ("cache") & "/theContent/" & tAudio)
else
set the defaultFolder to specialFolderPath("desktop")
play audioClip ("sounds/" & tAudio)
end if
wait 1 seconds
add 1 to x
end repeat

or


repeat while x< y
put line x of tmusic into tAudio

if the environment is mobile then
put (specialFolderPath ("cache") & "/theContent/" & tAudio) into tPath
put "queued" into tChannelName
put "next" into tType
mobilePlaySoundOnChannel tPath, tChannelName, tType
else
set the defaultFolder to specialFolderPath("desktop")
play audioClip ("sounds/" & tAudio)
end if
wait 1 seconds
add 1 to x
end repeat

I can get "the mouseClick" to be recognised on the mac, but not on the iPhone.
How can I interrupt the repeat?

All the best,
Jessamy

[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2262
Joined: Thu Feb 28, 2013 11:52 pm
Location: Göttingen, DE

Re: Stopping a list of musical notes

Post by [-hh] » Thu Jul 11, 2019 9:40 am

You could try:

Code: Select all

on mouseUp
  put ... into tAudio
  if the label of me is "Play" then
    set label of me to "Stop"
    if the environment is "mobile" then
      play (specialFolderPath ("cache") & "/theContent/" & tAudio)
    else
      set the defaultFolder to specialFolderPath("desktop")
      play audioClip ("sounds/" & tAudio)
    end if
  else 
     set label of me to "Play"
     play stop
   end if
end mouseUp
Last edited by [-hh] on Thu Jul 11, 2019 9:44 am, edited 1 time in total.
shiftLock happens

SparkOut
Posts: 2852
Joined: Sun Sep 23, 2007 4:58 pm

Re: Stopping a list of musical notes

Post by SparkOut » Thu Jul 11, 2019 9:44 am

Also in a repeat loop, a wait statement will be blocking.

Try :

Code: Select all

wait 1 seconds with messages
which should allow o/s housekeeping processes to deal with messages like button presses and so on.

jessamy99
Posts: 103
Joined: Thu Oct 25, 2012 3:23 pm

Re: Stopping a list of musical notes

Post by jessamy99 » Thu Jul 11, 2019 9:58 pm

Thankyou both very much!

I actually used the second idea and it works perfectly!

Much appreciated.
All the best,
Jessamy

Post Reply

Return to “iOS Deployment”