At the moment, I record a sound (Record1, Record2, Record3 etc.), stop the recording (Stop1, 2, 3 etc) and play the sound (tSound) with button Play1, Play2, Play3 etc) and it plays to the end .. All working fine and not a problem but it plays to the end without any user controls which could be problematic with longer sounds, in which case it would be far better to ALSO have the playback controlled by the Player object, which I just added.
I am having trouble also sending the sound to Player P1 to allow users to Start/Stop the sound if it's longer and set up an environment where they can play a short sound (Play1) or a long sound (Player object P1).
The 'Record' script on button Record1 is:
Code: Select all
on mouseUp
put the cUserDefinedRecordingFolder of this card into tUserFolder
## User did not define a folder yet:
if there is not a folder tUserFolder then
answer folder "Select a folder for the recordings:"
if the result is cancel then
exit to top
end if
## We store the folder also in a custom property:
set the cUserDefinedRecordingFolder of this stack to IT
## We need this in this script:
put it into tUserFolder
end if
set the recordFormat to "wav"
ask "Please name the recording:"
if it = empty then
exit to top
end if
put it into tUserDefinedName
put tUserFolder & "/" & tUserDefinedName & ".wav" into tFile
## Now set two custom properties fo the PLAY1 button, so the button knows what to play when clicked!
set the cAudioFile of btn "play1" to tFile
set the cUserDefinedName of btn "play1" to tUserDefinedName
mergMicrophoneStartRecording tFile
set the label of button "Record1" to "Recording"
##
end mouseUp
Code: Select all
on mouseUp
put the cAudioFile of me into tFile
put the cUserDefinedName of me into tUserDefinedName
if tFile = EMPTY then
## Nothing recorded yet!
exit to top
end if
play tFile
set the label of button "Play1" to "Playing"
wait until the sound is done
set the label of button "Play1" to "Play1"
##
end mouseUp