Page 1 of 1

Preventing the Import of an AudioClip Already There

Posted: Sat Jan 09, 2016 3:03 am
by deeverd
Hello Forum,

This is probably a rather basic question but it represents my latest several hours of frustration and document searching. How do I prevent the user from importing the same audioClip into a standalone twice?

My thought is that if I could have the program first retrieve a list of the audioClip names that are already in the stack, put those names into a variable or field, and then compare that list to the name of the audioClip they are presently trying to import, it would be easy to stop the import with a simple "if then else & exit mouseUp."

The problem for me is really two:

1) I still have not been able to figure out how to call up all the names of the audioClips that are currently in a stack.

2) I haven't been able to figure out how to get the name of the audioClip I'm trying to import before it is placed into the stack. I can use code such as "put the name of last audioClip into tAudio" but that either only works for me to retrieve the previous audioClip that was imported or the present one after it is imported.

I am definitely perplexed by this simple operation.

Any suggestions pointing me in the right direction will be greatly appreciated.
All the best,
deeverd

Re: Preventing the Import of an AudioClip Already There

Posted: Sat Jan 09, 2016 10:16 am
by jmburnod
Hi Deeverd,
importing the same audioClip into a standalone
As far I know, you can't modify a standalone.
If you need add something to your app you have to use external files.
Best regards
Jean-Marc

Re: Preventing the Import of an AudioClip Already There

Posted: Sat Jan 09, 2016 12:03 pm
by Klaus
Hi all,

I think you CAN actually import stuff into a standalone, but all that is lost when you quit!

Since "audioclip" and "videoclip" are real dinosaurs, there is obviously no way to manage them sufficiently. :(

If you do not want to use PLAYER objects, I would manage the users audioclips manually in a (text) list that
you can control and also save on the users harddisk, but these audioclips can still be played:
...
play ac "path/to/audifile.au"
...
Looks like this approach is even more efficient in your case.


Best

Klaus

Re: Preventing the Import of an AudioClip Already There

Posted: Sat Jan 09, 2016 5:24 pm
by deeverd
Hi Thanks for the Help,

First off, my apologies for not explaining my question better. I can see that I confused everyone by the way I used the term "standalone." By standalone, I was thinking of the whole program, including the editable stack in the folder with the standalone. It is the editable stack with which I am concerned.

In reality, it would be best to completely forget the term "standalone." What I meant is if the users are importing wave files into an editable stack (Windows system), how does one accomplish the task I have outlined in the code below?

Code: Select all

answer file "Select an audio wave file for input:" with filter "Audio files, *.wav"
   
   if it is empty then exit mouseUp 
   

   --1. if it is not empty then extract the name of the audioClip file being imported and put that name into a temporary variable tAudiotImport
   
   --2. retrieve a list of wave files that have already been imported into the editable stack and put that list into a temporary variable tCurrentList
   
   --3. check to see if the new tAudtioImport is found in tCurrentList (if that audio has already been imported into the stack and remains there)
   
   --4. if so, prevent the importation of the audioClip being selected by the user from being imported into the stack again
   
   import audioClip from file it
The two parts of the code that I don't know how to accomplish are 1 & 2 (1. getting the name of the wave file that the user is trying to import before it is actually imported into the stack; and 2. retrieving a list of the short names of the audioClips that are already residing in the editable stack).

Again, my apologies for confusing the original question with the word "standalone," which I was not accurately using.

Cheers,
deeverd

Re: Preventing the Import of an AudioClip Already There

Posted: Sat Jan 09, 2016 5:57 pm
by deeverd
Hello all,

A moment ago, I discovered half of the answer I was seeking by finding a way of retrieving the audioClip names embedded in a stack:

Code: Select all

on mouseUp
   
   repeat with x = 1 to (the number of audioclips of this stack)
      #put the long id of audioClip x of this stack & cr after tCtlRef -- if I want id numbers with filepath
      #put the short id of audioClip x of this stack & cr after tCtlRef -- if I want id numbers only
      put the name of audioClip x of this stack & cr after tCtlRef -- if I want the actual name of the file
   end repeat
   put tCtlRef into field "audioListField"
   
end mouseUp
I just found this particular code (which I added to) from a Google search that located a forum discussion back in 2008.

What I still can't figure out is how to extract the name of the audio file that is being selected for import, in order to see if it is already in the stack, before completing the import.

Cheers,
deeverd

Re: Preventing the Import of an AudioClip Already There

Posted: Sat Jan 09, 2016 6:02 pm
by Klaus
Hi deeverd,

forget what? :D

I understood your problem right away!
I have just searched the complete IDE to see how the mothership manages imported clips
and found that this is how it works (after audioclipS did not show up in the dictionary :( ).

Made al little test stack with 2 imported audioclips:

Code: Select all

on mouseUp
   put the num of Audioclips of this stack into tList
   repeat with i = 1 to tList
      put the short name of audioclip i of this stack & CR after tList2
   end repeat
   put tList2
end mouseUp
Hope this helps!


Best

Klaus

Re: Preventing the Import of an AudioClip Already There

Posted: Sat Jan 09, 2016 6:03 pm
by Klaus
Oh, we both finally found it! :D

But you know how to extract the last item of a pathname after setting the itemdelimiter to "/", don't you? 8)

Re: Preventing the Import of an AudioClip Already There

Posted: Sat Jan 09, 2016 6:22 pm
by deeverd
Hello Klaus,

Glad we both came up with a solution, but to answer your question...
know how to extract the last item of a pathname after setting the itemdelimiter to "/", don't you?
Embarrassingly, :oops: no I don't know how. I'm not even sure how to capture the pathname before the import fully takes place, much less just grab the actual file name off the end of it to use for comparison.

I could definitely use that information. Thanks in advance,

deeverd

Re: Preventing the Import of an AudioClip Already There

Posted: Sat Jan 09, 2016 6:47 pm
by Klaus
Okie Dokie :D

Code: Select all

...
answer file "Select an audio wave file for input:" with filter "Audio files, *.wav"
## the pathname is not in the variable IT
## User may have clicked CANCEL
if IT = empty then
  exit to top
end if
set itemdel to "/"
put item -1 of IT into tAudioClipName
## Now do your comparison here...
## and finally decide to: import audioClip from file it
## or EXIT to top! :-)
...
Best

Klaus

Re: Preventing the Import of an AudioClip Already There

Posted: Sat Jan 09, 2016 7:00 pm
by deeverd
Hello Klaus,

Thank you so much. I'll incorporate your excellent insights into my coding right away. That really helps me a whole lot, not only for this project but for many future projects as well.

You do so much for so many LiveCode users on this site, I hope you also make a fortune as a consultant and developer. Your assistance really is appreciated and you definitely deserve to be rich!

Cheers :D ,
deeverd

Re: Preventing the Import of an AudioClip Already There

Posted: Sat Jan 09, 2016 7:18 pm
by Klaus
Hi deeverd,

thank you for your kind wishes, maybe you want to take look at my repsonses here:
http://forums.livecode.com/viewtopic.php?f=5&t=26204

Best

Klaus

Re: Preventing the Import of an AudioClip Already There

Posted: Sat Jan 09, 2016 9:28 pm
by deeverd
Congratulations Klaus!

8000 good deeds that you have done for others may perhaps top the number of good deeds accomplished by Mother Theresa. You have considered sainthood, right? I'm just saying.

After looking at the responses from the link you sent, I followed your music lead, which I'm pasting here for those who haven't had the privilege to see and hear you play. Kudos, big time! Your demo videos, especially the "Pop-Rock" and "Hard-Rock" demos are nothing short of amazing. If you told me you were in a group that gives concerts to 50,000 people at a time, I would believe it.

Klaus Demo Hard-Rock and Demo Pop-Rock:

http://www.major-k.de/bass/video.html

Klaus Audio Links:

http://www.major-k.de/bass/sounds.html

Wow, I am seriously impressed!

Hopefully, this doesn't sound cheesy, but I'm a big believer in karma, and you've done so much for so many, I hope the equivalent of your gifts come back to you in full measure... and more.
Here's a link for a music video that captures that spirit of giving that you possess. Their playing isn't nearly as good as your bass playing, but it's the thought that counts:

https://www.youtube.com/watch?v=nwAYpLVyeFU

Cheers,
deeverd

Re: Preventing the Import of an AudioClip Already There

Posted: Sat Jan 09, 2016 10:32 pm
by Klaus
Hi deeverd,

thank you for your kind words!
Mother Theresa

Huh, no, she is currently getting a very bad reputation after all these years... 8)
You have considered sainthood, right?
Nope, I don't believe in this stuff.
And I really think that is a TAD exaggerated :D


Best

Klaus