[Python code debugging version] here comes daughter love: quietly ask the holy monk, is your daughter beautiful? (great for my Python)

Posted by kitcorsa on Mon, 10 Jan 2022 00:09:01 +0100

preface

”If there is an afterlife, long songs sing in pairs, the beauty snuggles up beside her, thin clothes and long years. “    

When I was young, I always liked to see the clips of subduing demons and eliminating demons in journey to the West. I looked forward to it.

The four masters and disciples were able to overcome difficulties and dangers and get the Sutra. When they saw the episode of the kingdom of daughters, they felt insipid

It was even fortunate that the female king did not stop the way to get the Scriptures. Later, she learned that the difficulty of "9981" in journey to the West was the most difficult

"Ask the holy monk quietly, is your daughter beautiful?" Is the most beautiful love word in the world!

This pure music "daughter love" made of Python version code mode is given to you! I hope you like it~

Everything can be changed! Hahaha, music, games, sketches and other codes can be completed. There are more functions waiting for you to learn and keep up

My footsteps 👇👇

                                                   

text

First of all, remember to prepare the music score first! (more on this part)

1, Environmental preparation

Python 3, pychar, numpy, cv2 and other materials for making pictures are free to choose. We won't show them here. We'll give them later

Let's randomly find several groups of effects!

Installation of third-party library: pip  install +If there is a problem with the module name, you can directly find my private letter

2, Code demonstration

import os
import pygame
import sys
import re
from pygame.locals import*
pygame.mixer.init()
pygame.display.set_mode([30,30])


scale_list=[]#sound
scale_name=[]#The whole process of syllable
scale_time=[]#The duration of the stored tone, 8 diaeresis, 4...
scale_volume=[]#Storage volume
scale_rh=[]#Type of stored syllable
music_turn=[]#Play music
music1=[
    'l5_8','l6_8','m1_4','m1_8','m2_8','m3_8','l7_16','m6_16','l7_16','l5_8','l6_4','l6_4'
]
music2=[
    'm1_8','m2_8','m3_4','m3_4','m5_8','m6_8','m1_8','m2_16','m3_16','m4_8','m3_4','m3_4'
]
music3=['m3_8','m5_8','m6_4','m6_8','m5_8','m6_4','l6_8','m3_8','m2_4','m2_4','m1_8','m2_4']
music4=[
    'm3_4','l5_4','l5_8','l6_8','l7_8','m3_4','l6_8','l6_8','m1_4','m1_8','m1_4','m1_4'
]
music5=[
    'm5_8','m5_8','m6_8','m1_8','m7_4','m6_8','m5_8','m6_4','m6_4','m6_4','m6_4'
]
music6=[
    'm5_8','m5_8','m6_8','h1_8','m7_4','m6_16','m5_16','m3_4','m3_4','m3_4'
]
music=music1+music2+music3+music4+music5+music6
music_1=music#Manual translation
music_n=[]
path='./scale3'

for i in music_1:
    new1=i+'.wav'
    music_n.append(new1)



dict1={'2':2000,'4':1000,'8':500,'1':250}
for filename in os.listdir(r'./scale3'):
    #if not os.path.isdir(filename): 
    #sound=pygame.mixer.music.load(path+'/'+filename)
    sound=pygame.mixer.Sound(path+'/'+filename)
    sound.set_volume(0.2)
    scale_list.append(sound)
    scale_name.append(filename)


# for i in scale_name:
#     time=re.findall('.*?_(.*?).wav',i)#Get a fraction of time
#     scale_time.append(time)
#     a1=re.findall('(.*?)_.*?.wav',i)
#     scale_volume.append(a1[0])
#     scale_rh.append(a1[1])
#     print(time)

def get_vol(name):#Get pitch
    a1 = re.findall('(.*?)_.*?.wav', i.decode('utf-8'))
    return a1[0]

def get_rh(name):#Get the note name
    a1 = re.findall('(.*?)_.*?.wav', i.decode('utf-8'))
    return a1[1]

def get_time(name):#Get the duration of this sound
    fen = re.findall('.*?_(.*?).wav',i)
    return dict1[fen]




# # bool1=pygame.mixer.music.get_busy()
# # print(bool1)
# for i in scale_list:
#     index1=scale_list.index(i)
#     name=scale_name[index1]#The name of this syllable
#     print(name)
#     print(type(name))
#     i.play()
#     pygame.time.delay(int(dict1[name[3]])-5)
#     print(pygame.mixer.music.get_busy())
for name in music_n:
    index1 = scale_name.index(name)
    music=scale_list[index1]
    music.play()
    pygame.time.delay(int(dict1[name[3]]))

3, Effect display

1) Video effect display

Python version of "daughter love" is coming! Quietly ask the holy monk, is your daughter beautiful?

The screenshot shows no effect, because the words of music can't be reflected! So don't show the screenshot!

Summary

Python version of daughter love also has a different flavor! Hahaha, you have to play your own music! Clean hands!

Complete material, etc.: didi I acridine!

There are more source code waiting for you to lead the area!

Article summary——

Summary: Python article collection | (Introduction to actual combat, games, Turtle, cases, etc.)

Topics: Python Mini Program pygame