Cropping TWave

Please post bug reports, feature requests, or any question regarding the DELPHI AREA products here.

Cropping TWave

Postby stfine » April 1st, 2007, 12:25 pm

Hello. Thank you for the Wave Package - I use it a lot.

But now I have stumbled with cropping a wave loaded into TWave with a 1 sample accuracy. TWave.Delete takes a Pos argument in milliseconds and that provides only 44 sample resolution for 44100Hz audio stream. How can I delete, say, from 2000th sample to the end of file?

BTW, I didn't understand completely what is TWave.Crop intended for.

Thanks.
stfine
Active Member
Active Member
 
Posts: 12
Joined: August 1st, 2006, 7:00 am

Postby Kambiz » April 1st, 2007, 6:15 pm

To delete end of a wave audio from a position specified by the Pos variable use:

Wave.Delete(Pos, Wave.Length - Pos);

Consider that converting milliseconds to samples is approximated.

Regarding Crop method, suppose in a stream there is a wave audio appended with some other data, the Crop method removes the non-audio data.
Kambiz
User avatar
Kambiz
Administrator
Administrator
 
Posts: 2408
Joined: March 7th, 2003, 7:10 pm

Postby stfine » April 1st, 2007, 7:26 pm

Kambiz wrote:Consider that converting milliseconds to samples is approximated.


Dear Kambiz, I need to specify EXACT sample number, not approximated. If we have 44100 samples per second, that is approx. 44 samples per a millisecond. As I understood, Delete(1,1) corresponds to deleting 44 samples from offset 44. I'd rather have function that take sample numbers as arguments.

Example: to delete 50 samples from sample number 100.
stfine
Active Member
Active Member
 
Posts: 12
Joined: August 1st, 2006, 7:00 am

Postby Kambiz » April 2nd, 2007, 8:57 am

It means changing the average samples per second, and implies changing the wave format.
Kambiz
User avatar
Kambiz
Administrator
Administrator
 
Posts: 2408
Joined: March 7th, 2003, 7:10 pm

Postby stfine » April 2nd, 2007, 4:53 pm

It doesn't mean changing the average samples per second. For instance, if delete 1 sample from the beginning of the wave, how does it affects wave description? In no way. I just have deleted 0,023ms of sound.

Let me restate my request - the current realization is tailored to work with 1ms precision, while I want to manipulate wave with 1 sample precision.

I though about working with underlying TMemoryStream directly, but then I need somehow to update TWave fileds to reflect that changes. It seems to me not easier then bothering with Windows API functions without TWave class at all.

:roll:
stfine
Active Member
Active Member
 
Posts: 12
Joined: August 1st, 2006, 7:00 am

Postby Kambiz » April 2nd, 2007, 9:53 pm

If you look at Delete code, you will find out how to change wave data directly. It's easier to subclass TWave and introduce a new delete method for your purpose.
Kambiz
User avatar
Kambiz
Administrator
Administrator
 
Posts: 2408
Joined: March 7th, 2003, 7:10 pm


Return to DELPHI AREA Products

Who is online

Users browsing this forum: No registered users and 1 guest