1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
|
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# *
# Application gammique évolutive
# Opération = Envol système
# ProgamV1epyco
#
from tkinter import *
import winsound
import wave, math, binascii
# Partie échantillonnage
fichwav = []
toplo = [] # Le fichier présumé contenir le son de la note
nbOctet = nbCanal = 1 # # Mes lacunes: Premiers pas de conversion audio
fech = 44100 # # Ceci n'est que le premier problème
niveau = float(1)
duree = float(1/8)
nbEch = int(duree*fech)
for fy in range(7):
manote = wave.open(toplo[fy],'wb')
param = (nbCanal,nbOctet,fech,nbEch,'NONE','not compressed')
manote.setparams(param)
freq = 440 ; amp = 127.5*niveau
for i in range(0,nbEch):
val = wave.struct.pack('B',int(128.0 + amp*math.sin(2.0*math.pi*freq*i/fech)))
manote.writeframes(val) # écriture frame
fichwav.append(val)
manote.close()
for fw in range(7):
print('wav',type(toplo[f]))
print('wav',toplo[fw])
winsound.PlaySound(fichwav[fw])
Traceback (most recent call last):
File "C:/Users/Vincent/Documents/developpez/develHM/tutos/progamvaudio.py", line 20, in <module>
manote = wave.open(toplo[fy],'wb')
IndexError: list index out of range |
Partager