function p = gsm_pitch(file) % Syntax: p = gsm_pitch(filename) % % Reads EID file (text form) of GSM HR and retrieves the pitch information for % voiced frames. For unvoiced frames, it is set to 0. The length of p is % 4 times the number of frames, as we have a pitch information for each % subframe. Filename is a string with usually 'something.eid' psrLagTbl =[ ... 126, 128, 130, 132, 134, 136, 138, 139,... 140, 141, 142, 143, 144, 145, 146, 147,... 148, 149, 150, 151, 152, 153, 154, 155,... 156, 157, 158, 159, 160, 161, 162, 163,... 164, 165, 166, 167, 168, 169, 170, 171,... 172, 173, 174, 175, 176, 177, 178, 179,... 180, 181, 182, 183, 184, 185, 186, 187,... 188, 189, 190, 191, 192, 193, 194, 195,... 196, 197, 198, 199, 200, 201, 202, 203,... 204, 205, 206, 207, 208, 209, 210, 212,... 214, 216, 218, 220, 222, 224, 226, 228,... 230, 232, 234, 236, 238, 240, 242, 244,... 246, 248, 250, 252, 254, 256, 258, 260,... 262, 264, 266, 268, 270, 272, 274, 276,... 278, 280, 282, 284, 286, 288, 290, 292,... 294, 296, 298, 300, 303, 306, 309, 312,... 315, 318, 321, 324, 327, 330, 333, 336,... 339, 342, 345, 348, 351, 354, 357, 360,... 363, 366, 369, 372, 375, 378, 381, 384,... 387, 390, 393, 396, 399, 402, 405, 408,... 411, 414, 417, 420, 423, 426, 429, 432,... 435, 438, 441, 444, 447, 450, 453, 456,... 459, 462, 465, 468, 471, 474, 477, 480,... 483, 486, 489, 492, 495, 498, 501, 504,... 507, 510, 513, 516, 519, 522, 525, 528,... 531, 534, 537, 540, 546, 552, 558, 564,... 570, 576, 582, 588, 594, 600, 606, 612,... 618, 624, 630, 636, 642, 648, 654, 660,... 666, 672, 678, 684, 690, 696, 702, 708,... 714, 720, 726, 732, 738, 744, 750, 756,... 762, 768, 774, 780, 786, 792, 798, 804,... 810, 816, 822, 828, 834, 840, 846, 852 ]; fid = fopen (file, 'r'); gsm = fscanf (fid, '%d', [18, inf]); % lines to columns, one line = 18 items gsm = gsm'; % now one line in file = one line in matrix frames = size (gsm,1); p=zeros(1, 4*frames); icur_sfrm=1; for icur_frm=1:frames, if (gsm(icur_frm,1) == 0), % UNVOICED p(icur_sfrm) = 0; p(icur_sfrm+1) = 0; p(icur_sfrm+2) = 0; p(icur_sfrm+3) = 0; else % VOICED index1 = gsm(icur_frm, 7) + 1; % absolute coding, +1 for Matlab index2 = index1 + gsm(icur_frm, 8) - 8; % differential coding index3 = index2 + gsm(icur_frm, 9) - 8; % diff. c. index4 = index3 + gsm(icur_frm, 10) - 8; % diff. c. p(icur_sfrm) = psrLagTbl(index1); p(icur_sfrm+1) = psrLagTbl(index2); p(icur_sfrm+2) = psrLagTbl(index3); p(icur_sfrm+3) = psrLagTbl(index4); end % of if voiced/unvoiced icur_sfrm = icur_sfrm + 4; end % of for p = p / 6; % division by os factor