first commit
This commit is contained in:
commit
417e54da96
5696 changed files with 900003 additions and 0 deletions
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
59
kivy_venv/share/kivy-examples/audio/audio.kv
Normal file
59
kivy_venv/share/kivy-examples/audio/audio.kv
Normal file
|
@ -0,0 +1,59 @@
|
|||
#:kivy 1.0
|
||||
#:import kivy kivy
|
||||
|
||||
<AudioBackground>:
|
||||
orientation: 'vertical'
|
||||
canvas:
|
||||
Color:
|
||||
rgb: 1, 1, 1
|
||||
Rectangle:
|
||||
source: 'data/images/background.jpg'
|
||||
size: self.size
|
||||
|
||||
BoxLayout:
|
||||
padding: 10
|
||||
spacing: 10
|
||||
size_hint: 1, None
|
||||
pos_hint: {'top': 1}
|
||||
height: 44
|
||||
Image:
|
||||
size_hint: None, None
|
||||
size: 24, 24
|
||||
source: 'data/logo/kivy-icon-24.png'
|
||||
Label:
|
||||
height: 24
|
||||
text_size: self.size
|
||||
color: (1, 1, 1, .8)
|
||||
text: 'Kivy %s - Audio sample' % kivy.__version__
|
||||
valign: 'middle'
|
||||
|
||||
Label:
|
||||
text: 'Audio example'
|
||||
font_size: 32
|
||||
size_hint_y: None
|
||||
|
||||
BoxLayout:
|
||||
Slider:
|
||||
min: 0.0
|
||||
max: 1.0
|
||||
value: 1.0
|
||||
on_value: app.set_volume(self.value)
|
||||
orientation: "vertical"
|
||||
size_hint_x: None
|
||||
width: "48dp"
|
||||
|
||||
StackLayout:
|
||||
id: sl
|
||||
|
||||
Button:
|
||||
text: 'Stop and release all audio'
|
||||
size_hint_y: None
|
||||
height: '50sp'
|
||||
on_press: app.release_audio()
|
||||
|
||||
<AudioButton>:
|
||||
size_hint: None,0.333
|
||||
width: self.height
|
||||
text_size: self.size
|
||||
font_size: '12sp'
|
||||
valign: 'middle'
|
81
kivy_venv/share/kivy-examples/audio/main.py
Normal file
81
kivy_venv/share/kivy-examples/audio/main.py
Normal file
|
@ -0,0 +1,81 @@
|
|||
'''
|
||||
Audio example
|
||||
=============
|
||||
|
||||
This example plays sounds of different formats. You should see a grid of
|
||||
buttons labelled with filenames. Clicking on the buttons will play, or
|
||||
restart, each sound. Not all sound formats will play on all platforms.
|
||||
|
||||
All the sounds are from the http://woolyss.com/chipmusic-samples.php
|
||||
"THE FREESOUND PROJECT", Under Creative Commons Sampling Plus 1.0 License.
|
||||
|
||||
'''
|
||||
|
||||
import kivy
|
||||
kivy.require('1.0.8')
|
||||
|
||||
from kivy.app import App
|
||||
from kivy.uix.button import Button
|
||||
from kivy.uix.boxlayout import BoxLayout
|
||||
from kivy.core.audio import SoundLoader
|
||||
from kivy.properties import StringProperty, ObjectProperty, NumericProperty
|
||||
from glob import glob
|
||||
from os.path import dirname, join, basename
|
||||
|
||||
|
||||
class AudioButton(Button):
|
||||
|
||||
filename = StringProperty(None)
|
||||
sound = ObjectProperty(None, allownone=True)
|
||||
volume = NumericProperty(1.0)
|
||||
|
||||
def on_press(self):
|
||||
if self.sound is None:
|
||||
self.sound = SoundLoader.load(self.filename)
|
||||
# stop the sound if it's currently playing
|
||||
if self.sound.state != 'stop':
|
||||
self.sound.stop()
|
||||
self.sound.volume = self.volume
|
||||
self.sound.play()
|
||||
|
||||
def release_audio(self):
|
||||
if self.sound:
|
||||
self.sound.stop()
|
||||
self.sound.unload()
|
||||
self.sound = None
|
||||
|
||||
def set_volume(self, volume):
|
||||
self.volume = volume
|
||||
if self.sound:
|
||||
self.sound.volume = volume
|
||||
|
||||
|
||||
class AudioBackground(BoxLayout):
|
||||
pass
|
||||
|
||||
|
||||
class AudioApp(App):
|
||||
|
||||
def build(self):
|
||||
|
||||
root = AudioBackground(spacing=5)
|
||||
for fn in glob(join(dirname(__file__), '*.wav')):
|
||||
btn = AudioButton(
|
||||
text=basename(fn[:-4]).replace('_', ' '), filename=fn,
|
||||
size_hint=(None, None), halign='center',
|
||||
size=(128, 128), text_size=(118, None))
|
||||
root.ids.sl.add_widget(btn)
|
||||
|
||||
return root
|
||||
|
||||
def release_audio(self):
|
||||
for audiobutton in self.root.ids.sl.children:
|
||||
audiobutton.release_audio()
|
||||
|
||||
def set_volume(self, value):
|
||||
for audiobutton in self.root.ids.sl.children:
|
||||
audiobutton.set_volume(value)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
AudioApp().run()
|
42
kivy_venv/share/kivy-examples/audio/pitch.py
Normal file
42
kivy_venv/share/kivy-examples/audio/pitch.py
Normal file
|
@ -0,0 +1,42 @@
|
|||
# encoding: utf8
|
||||
|
||||
from kivy.app import App
|
||||
from kivy.core.audio import SoundLoader
|
||||
from kivy.uix.boxlayout import BoxLayout
|
||||
from kivy.uix.button import Button
|
||||
|
||||
from sys import version_info
|
||||
|
||||
|
||||
NOTES = (
|
||||
('Do', 1),
|
||||
('Ré', 9 / 8.),
|
||||
('Mi', 5 / 4.),
|
||||
('Fa', 4 / 3.),
|
||||
('Sol', 3 / 2.),
|
||||
('La', 5 / 3.),
|
||||
('Si', 15 / 8.),
|
||||
)
|
||||
|
||||
|
||||
class Test(App):
|
||||
def build(self):
|
||||
self.sound = SoundLoader.load(
|
||||
'/usr/lib64/python{}.{}/test/audiodata/pluck-pcm32.wav'
|
||||
.format(*version_info[0:2])
|
||||
)
|
||||
root = BoxLayout()
|
||||
for octave in range(-2, 3):
|
||||
for note, pitch in NOTES:
|
||||
button = Button(text=note)
|
||||
button.pitch = pitch * 2 ** octave
|
||||
button.bind(on_release=self.play_note)
|
||||
root.add_widget(button)
|
||||
return root
|
||||
|
||||
def play_note(self, button):
|
||||
self.sound.pitch = button.pitch
|
||||
self.sound.play()
|
||||
|
||||
|
||||
Test().run()
|
Loading…
Add table
Add a link
Reference in a new issue