Is it possible to crop auido file?


#1

Now i can record .wav file ,  and next step i want to crop some part of it . I try to find some class that would help but i still haven't found what i'm looking for .

 

some guide pls :D


#2

Load file into buffer. Crop buffer. Write buffer to new file, or replace existing one....


#3

aha but i dont know which operator that use for crop a buffer ...

 

sorry for my noob , but im so new with audio programming ...


#4

There is no 'crop' operator. Just resize the buffer. 


#5


i always load file like this ... and i dont know anything about how to use buffer ...

AudioFormatReader* reader = formatmager.createReaderFor (file);

readersource = new AudioFormatReaderSource (reader, true);

transportsource.setSource (readersource);

can u guide me more ? :D


#6

This is not something I've done before but it seems to me that you should load the sound file into an AudioBufferSample. Once it's in the buffer you can manipulate it as you like. Then when it's done, you can write the buffer to disk. Others on the list might be able to suggest other ways to do it. Anyhow, it's all in the docs. You'll just have to do some digging :)

http://www.juce.com/api/classAudioFormatReader.html
http://www.juce.com/api/classAudioSampleBuffer.html

 

 

 

 


#7

oh , i can do it now ! 

here is my code :D

                int size=320000;

                AudioSampleBuffer* buffer=new AudioSampleBuffer(1,size);

                buffer->clear();

                reader->read(buffer, 0, 51200,0 ,false, false);

                ScopedPointer<WavAudioFormat> wavFormat =  new WavAudioFormat();

                File bufferfile = File("/Users/BukerBear/Documents/yourfile.wav");

                bufferfile.deleteFile();

                FileOutputStream* filestream = bufferfile.createOutputStream();

                AudioFormatWriter* writer =  wavFormat->createWriterFor(filestream , 44100, 1, 16,StringPairArray(), 0);

               if( writer->writeFromAudioSampleBuffer(*buffer, 35600, 51200))

                {

                   delete writer;

                }

 

ps .i decided to use juce for my university project ... Thank you Rory, you've helped me a lot!


#8

Good luck with your project :)