1#!/usr/bin/env python 2import numpy as np 3import wave 4import struct 5import sys 6import time 7from sbc import * 8 9matrix_R = np.zeros(shape = (16,8)) 10matrix_C2 = np.zeros(shape = (8,8)) 11matrix_N = np.zeros(shape = (16,16)) 12 13def sbc_init_synthesis_v1(M): 14 global matrix_R, matrix_C2, matrix_N 15 if M == 4: 16 print("SBC V1 init failed, 4-subband version not implemented yet") 17 M2 = M << 1 18 Mh = M >> 1 19 20 matrix_R = np.zeros(shape = (M2,M)) 21 matrix_C2 = np.zeros(shape = (M,M)) 22 matrix_N = np.zeros(shape = (M2,M2)) 23 24 R_c1 = 12 25 26 for k in range(Mh): 27 matrix_R[k][k+Mh] = 1 28 29 for k in range(Mh+1,M2): 30 matrix_R[k][abs(R_c1-k)] = -1 31 32 for k in range(M): 33 for i in range(M): 34 matrix_C2[k][i] = np.cos((i+0.5)*k*np.pi/M) 35 36 matrix_N = np.dot(matrix_R, matrix_C2) 37 38def sbc_frame_synthesis_v1_4subbands(frame, ch, blk): 39 print "sbc_frame_synthesis_v1_4subbands(frame, ch, blk) not implemented yet" 40 exit(1) 41 42def sbc_frame_synthesis_v1_8subbands(frame, ch, blk): 43 print "sbc_frame_synthesis_v1_8subbands(frame, ch, blk) not implemented yet" 44 exit(1) 45 46def matrix_R(): 47 global matrix_R 48 return matrix_R 49 50def matrix_C2(): 51 global matrix_C2 52 return matrix_C2 53 54def matrix_N(): 55 global matrix_N 56 return matrix_N 57 58def R(k,i): 59 global matrix_R 60 return matrix_R[k][i] 61 62def C2(k,i): 63 global matrix_C2 64 return matrix_C2[k][i]