Пример #1
0
    def __init__(self, **kwargs):
        super(MainWidget, self).__init__(**kwargs)
        self.sound_kit_service = SoundKitService()

        # kick_sound = self.sound_kit_service.get_sound_at(0)

        self.audio_engine = AudioEngine()
        # self.audio_engine.play_sound(kick_sound.samples)

        # self.audio_engine.create_track(kick_sound.samples, 120)

        self.mixer = self.audio_engine.create_mixer(
            self.sound_kit_service.soundkit.get_all_samples(), self.bpm,
            TRACK_NB_STEPS, self.on_mixer_current_step_changed, MIN_BPM)
Пример #2
0
 def __init__(self, **kwargs):
     super(RelativeLayout, self).__init__(**kwargs)
     self.init_check_params()
     self.init_window_size()
     self.AE = AudioEngine()
     self.SKS = SoundKitService(self.nbr_groups, self.AE, self.BPM_VALUE,
                                self.NBR_STEPS_PER_TRACK, self.SOUND_KIT_ID)
Пример #3
0
class MainWidget(RelativeLayout):
    tracks_layout = ObjectProperty()
    play_indicator_widget = ObjectProperty()
    TRACK_STEPS_LEFT_ALIGN = NumericProperty(dp(100))
    step_index = 0
    bpm = NumericProperty(115)

    def __init__(self, **kwargs):
        super(MainWidget, self).__init__(**kwargs)
        self.sound_kit_service = SoundKitService()

        # kick_sound = self.sound_kit_service.get_sound_at(0)

        self.audio_engine = AudioEngine()
        # self.audio_engine.play_sound(kick_sound.samples)

        # self.audio_engine.create_track(kick_sound.samples, 120)

        self.mixer = self.audio_engine.create_mixer(
            self.sound_kit_service.soundkit.get_all_samples(), self.bpm,
            TRACK_NB_STEPS, self.on_mixer_current_step_changed, MIN_BPM)

    def on_parent(self, widget, parent):
        self.play_indicator_widget.set_nb_steps(TRACK_NB_STEPS)
        # self.play_indicator_widget.set_current_step_index(8)
        for i in range(0, self.sound_kit_service.get_nb_tracks()):
            sound = self.sound_kit_service.get_sound_at(i)
            self.tracks_layout.add_widget(
                TrackWidget(sound, self.audio_engine, TRACK_NB_STEPS,
                            self.mixer.tracks[i], self.TRACK_STEPS_LEFT_ALIGN))

    def on_mixer_current_step_changed(self, step_index):
        # print("on_mixer_current_step_changed : " + str(step_index))
        self.step_index = step_index
        Clock.schedule_once(self.update_play_indicator_cbk, 0)

    def update_play_indicator_cbk(self, dt):
        if self.play_indicator_widget is not None:
            self.play_indicator_widget.set_current_step_index(self.step_index)

    def on_play_button_pressed(self):
        self.mixer.audio_play()

    def on_stop_button_pressed(self):
        self.mixer.audio_stop()

    def on_bpm(self, widget, value):
        print("BPM: " + str(value))
        # 80 - 160
        if value < MIN_BPM:
            self.bpm = MIN_BPM
            return
        if value > MAX_BPM:
            self.bpm = MAX_BPM
            return

        # ...(bpm au moteur audio)
        self.mixer.set_bpm(self.bpm)
Пример #4
0
class MainWidget(RelativeLayout):
    tracks_layout = ObjectProperty()

    def __init__(self, **kwargs):
        super(MainWidget, self).__init__(**kwargs)
        self.sound_kit_service = SoundKitService()

        # kick_sound = self.sound_kit_service.get_sound_at(0)

        self.audio_engine = AudioEngine()
        # self.audio_engine.play_sound(kick_sound.samples)

        # self.audio_engine.create_track(kick_sound.samples, 120)

        self.mixer = self.audio_engine.create_mixer(
            self.sound_kit_service.soundkit.get_all_samples(), 120,
            TRACK_NB_STEPS)

    def on_parent(self, widget, parent):
        for i in range(0, self.sound_kit_service.get_nb_tracks()):
            sound = self.sound_kit_service.get_sound_at(i)
            self.tracks_layout.add_widget(
                TrackWidget(sound, self.audio_engine, TRACK_NB_STEPS,
                            self.mixer.tracks[i]))