0

Greetings, first, I'm totally new to python.

What I'm attempting to do is rebuild a clipped off sound wave.

As I've been poking around I've come across things like "cubic spline interpolation" (that sounds like what I need -- but really is way over my head)

I've come across other posts that I've gleaned some code from and have put together the following test program.

The data points are from a real (clean) wave cycle out of a sound file.

I'm then clipping a number of them to simulate a clipped wave.

The spline and interp1d routines do run, but output what I'm putting in.

So, looking for some experience/help/direction ... thanks

What I'd like to see are values similar to the original values I clipped.

```
#! python3.2
import sys
import os
import numpy as np
from struct import *
from scipy.interpolate import InterpolatedUnivariateSpline as spline
from scipy.interpolate import interp1d
wave = '''
728
2563
4520
6387
8044
9518
10874
12175
13418
14489
15259
15744
16005
16065
15963
15733
15400
14922
14251
13281
12007
10525
8927
7281
5609
3756
1712'''.strip().splitlines()
y_wavearray = np.array(wave,np.float64)
y_wavearray[14] = y_wavearray[13] # clip top points
y_wavearray[15] = y_wavearray[14]
y_wavearray[16] = y_wavearray[15]
y_wavearray[17] = y_wavearray[16]
x_points = len(wave) +1
x_values = np.arange(1,x_points)
x_array = np.array(x_values,np.float64)
#cubic = spline(x_array, y_wavearray)
#for i in range(1,x_points):
# print(i, wave[i-1], int(cubic(i) +.5))
cubic = interp1d(x_values, y_wavearray, kind='cubic')
for i in range(1,x_points):
print(i, wave[i-1], int(cubic(i) +.5))
```