pbos@webrtc.org | 788acd1 | 2014-12-15 09:41:24 +0000 | [diff] [blame^] | 1 | function [x, t] = readPCM(file, fs) |
2 | %[x, t] = readPCM(file, fs) | ||||
3 | % | ||||
4 | %Reads a signal from a PCM file. | ||||
5 | % | ||||
6 | %x: The read signal after normalization. | ||||
7 | %t: The respective time vector. | ||||
8 | % | ||||
9 | %file: The PCM file where the signal is stored in int16 format. | ||||
10 | %fs: The signal sample rate in Hertz. | ||||
11 | fid = fopen(file); | ||||
12 | x = fread(fid, inf, 'int16'); | ||||
13 | fclose(fid); | ||||
14 | x = x - mean(x); | ||||
15 | x = x / max(abs(x)); | ||||
16 | t = 0:(1 / fs):((length(x) - 1) / fs); |