How to decrease total samples of audio?

7 views (last 30 days)
Nasuhcan TÜRKER
Nasuhcan TÜRKER on 14 Apr 2020
Answered: Walter Roberson on 14 Apr 2020
Hello,
I want to decrease total samples of my audio. My SampleRate: 10000 and total samples is 329000 but I want decrease to 44100. I try that downsample method but ı cant succesful. after that ı try to audiowrite(newfile, y, fs2); like this way audiowrite('myaudio.wav',44100,10000) but I got the this error message;
Warning: Data clipped when writing file.
> In audiowrite>clipInputData (line 407)
In audiowrite (line 187)
I would be grateful if someone help me.
  2 Comments
Geoff Hayes
Geoff Hayes on 14 Apr 2020
Edited: Geoff Hayes on 14 Apr 2020
Nasuhcan - from your comment SampleRate: 10000 but I want decrease to 44100, are you really trying to reduce the total number of samples, or are you changing the sampling rate? Why 44100? If you are reducing the number of samples from 329000 to 44100 (~13.4% reduction), will you keep the same sampling rate of 10000?
Nasuhcan TÜRKER
Nasuhcan TÜRKER on 14 Apr 2020
Hello firstly thanks you for your comment. I want decrease my total samples to 44100 because I am trying to write a deep learning algorithm that performs sound analysis and my needs are 44100 but some audio is old a record and are total samples is 329000 also my new code working on 44100 so ı must to decrease to my total samples and sampling rate is haven't be 10000. So I try to decrease old record's total samples.

Sign in to comment.

Answers (1)

Walter Roberson
Walter Roberson on 14 Apr 2020
audiowrite does not resample. The data you pass as the second parameter to it is the samples, so you are passing a single sample with value 44100. Notice how you did not pass your signal y to audiowrite. And NO, you cannot audiowrite a signal and then call audiowrite again with the same file name with the intention that audiowrite would somehow know that your intention was for it to read the file and resample it and write it back.
You should be using resample() to create a modified signal that you audiowrite

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!