Spaces:
Sleeping
Sleeping
File size: 1,364 Bytes
5e84ffc 448b42a 5e84ffc 448b42a 5e84ffc |
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 39 40 41 42 43 44 45 46 47 48 49 50 51 |
"""Base class for melody practice applications."""
from abc import ABC, abstractmethod
from typing import Any, Optional
import numpy as np
from improvisation_lab.config import Config
from improvisation_lab.service.base_practice_service import BasePracticeService
class BasePracticeApp(ABC):
"""Base class for melody practice applications."""
def __init__(self, service: BasePracticeService, config: Config):
"""Initialize the application.
Args:
service: BasePracticeService instance.
config: Config instance.
"""
self.service = service
self.config = config
self.phrases: Optional[Any] = None
self.current_phrase_idx: int = 0
self.current_note_idx: int = 0
self.is_running: bool = False
@abstractmethod
def _process_audio_callback(self, audio_data: np.ndarray):
"""Process incoming audio data and update the application state.
Args:
audio_data: Audio data to process.
"""
pass
@abstractmethod
def _advance_to_next_note(self):
"""Advance to the next note or phrase."""
pass
@abstractmethod
def launch(self, **kwargs):
"""Launch the application.
Args:
**kwargs: Additional keyword arguments for the launch method.
"""
pass
|