get endTime of a word in an aiff file

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

get endTime of a word in an aiff file

Post by jmburnod » Wed Aug 03, 2011 10:41 am

Hi All,
I have aiff files.
Each file contains one word in french and one in arabic with a silence (not absolute) between them.
(One is in attachment)
Is there a way to get the end (in milliseconds) of the french word and keep it somewhere in the file ?

Best
Jean-Marc
Attachments
manger.aiff.zip
a aiff file with two words
(84.37 KiB) Downloaded 294 times
https://alternatic.ch

BvG
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1239
Joined: Sat Apr 08, 2006 1:10 pm
Contact:

Re: get endTime of a word in an aiff file

Post by BvG » Wed Aug 03, 2011 5:32 pm

I'm sure it's possible. However, you'd need to understand how the AIFF file format works. Try googling for "AIFF specification", and read up on how the file is formatted.

After understanding what to do, you would use the binaryDecode and binaryEncode handlers to get the data that you want, modify it or replace it in the file.

Note that the AIFF format might or might not have the capability to store arbitrary data like timestamps. Again, you'd need to look up the specs, and then decide if you want to store it inside the file or just next to it as a seperate text file. (which I can assure you would be much simpler).
Various teststacks and stuff:
http://bjoernke.com

Chat with other RunRev developers:
chat.freenode.net:6666 #livecode

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: get endTime of a word in an aiff file

Post by jmburnod » Wed Aug 03, 2011 6:41 pm

Hi BvG,
I'm sure it's possible. However, you'd need to understand how the AIFF file format works. Try googling for "AIFF specification", and read up on how the file is formatted
Thank. I look and i'l come back

Best

Jean-Marc
https://alternatic.ch

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: get endTime of a word in an aiff file

Post by jmburnod » Fri Aug 05, 2011 11:01 pm

Hi BvG

I have read some documentation about aiff structure file.
It is probably possible to write the currentime of a player in a part of the file, but it seems delicate and obviously only valid for aiff file

I search a way which is useful for all sound types.

Is it a reasonable way to save the file as "frenchname_currentime_translation.aiff"
like this for arabic :

manger_550_adisha.aiff

fortunately the arabic word not with arabic font :)

Best

Jean-Marc
https://alternatic.ch

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: get endTime of a word in an aiff file

Post by jmburnod » Fri Sep 02, 2011 11:14 pm

Hi All,

I test a way to store the seperate time code between two words in the name of the file

Comment and other ways are welcome

Best regards

Jean-Marc
Attachments
PlayPartOfSound.zip
(90.13 KiB) Downloaded 280 times
Last edited by jmburnod on Fri Sep 02, 2011 11:41 pm, edited 1 time in total.
https://alternatic.ch

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: get endTime of a word in an aiff file

Post by jmburnod » Fri Sep 02, 2011 11:39 pm

Hi,

Sorry
An error in the buildPath handler. I forget restaure the itemdel to ","
I change the attachment of my previous post

Code: Select all

on BuildPath
   put the filename of this stack into PathFol
   set the itemdel to "/"
   put "SoundArabicFrench" into item-1 of PathFol
     set the itemdel to "," --restaure itemdel
   set the defaultfolder to PathFol
   put PathFol&"/"&"adisha_642_manger.aiff" into tPathFileSnd
   set the filename of player sPlayer to tPathFileSnd
   AjustWordTime tPathFileSnd
end BuildPath
Jean-Marc
https://alternatic.ch

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7393
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: get endTime of a word in an aiff file

Post by jacque » Sat Sep 03, 2011 10:56 pm

You can get "the duration" of a player, which will give you the total time of the sound file. The duration is not in seconds, so if you need to know the total seconds, then you must divide the duration by the player's timescale property.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: get endTime of a word in an aiff file

Post by jmburnod » Sun Sep 04, 2011 11:05 am

Hi Jacque,

Thank for your reply.
I don't need the total time in seconds.
I have two words in an aiff file, i search the best way to store the endTime of the first word
Best regards

Jean-Marc
https://alternatic.ch

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7393
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: get endTime of a word in an aiff file

Post by jacque » Sun Sep 04, 2011 6:52 pm

I see. You'll need to do that manually, but you only need to do it once during development. Load the sound file into a player and play it until the end of the first word, then pause it. In the message box or a button, get the currentTime of the player. That will tell you where the word ends. Then you can store number that anywhere you like -- in a field, a custom property, a text file, whatever is best for your stack. You can store the time in timescale units so that your scripts can use the number directly with the player later. You won't need to calculate seconds.

You could script a temporary stack with a player and a button that does this more quickly if you want. When the button is clicked have it stop the player and record the currentTime into a field.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: get endTime of a word in an aiff file

Post by jmburnod » Sun Sep 04, 2011 11:44 pm

Hi Jacque,
You could script a temporary stack with a player and a button that does this more quickly if you want. When the button is clicked have it stop the player and record the currentTime into a field.
Oh Yes. Why not two players in the same card and that should be more easy to compare the current and the new timeCode
Thank. I'll do that.

Jean-Marc
https://alternatic.ch

Post Reply