# Path: telluride_decoding/result_store.py
# class NumpyStore(object):
# class WindowedDataStore(NumpyStore):
# class TwoResultStore(object):
#   def __init__(self, init_frame_count=10000, name='Generic'):
#   def count(self):
#   def all_data(self):
#   def create_storage(self, data):
#   def _grow_storage(self, data):
#   def add_data(self, data):
#   def next_window(self, window_size):
#   def __init__(self, window_step=100, window_width=None, pre_context=0,
#                initial_frame_count=100):
#   def create_storage(self, data):
#   def next_window(self):
#   def __init__(self, window_width=100, window_step=100, pre_context=0,
#                initial_frame_count=100):
#   def all_data(self):
#   def add_data(self, s1, s2):
#   def next_window(self):


import numpy as np
from telluride_decoding import result_store
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================

"""Code to compute the audio intensity for preprocessing.

Code that stores incoming arbitrary audio data, and then yields fixed window
sizes for processing (like computing the intensity.)

After initializing the object, add a block of data to the object, and then
pull fixed sized blocks of data with a given half_window_width, and separated
by window_step samples. Data is always X x num_features, where X can change from
add_data call to call, but num_features must not change. Do not reuse the object
because it has internal state from previous calls.

"""




class AudioIntensityStore(result_store.WindowedDataStore):
  """Process a window of data, calculating the mean-squared value.
  """

  def next_window(self):
    for win in super(AudioIntensityStore, self).next_window():
      yield np.mean(np.square(win))



# Path: telluride_decoding/result_store.py
# class NumpyStore(object):
# class WindowedDataStore(NumpyStore):
# class TwoResultStore(object):
#   def __init__(self, init_frame_count=10000, name='Generic'):
#   def count(self):
#   def all_data(self):
#   def create_storage(self, data):
#   def _grow_storage(self, data):
#   def add_data(self, data):
#   def next_window(self, window_size):
#   def __init__(self, window_step=100, window_width=None, pre_context=0,
#                initial_frame_count=100):
#   def create_storage(self, data):
#   def next_window(self):
#   def __init__(self, window_width=100, window_step=100, pre_context=0,
#                initial_frame_count=100):
#   def all_data(self):
#   def add_data(self, s1, s2):
#   def next_window(self):


# Path: telluride_decoding/preprocess_audio.py
import numpy as np
from telluride_decoding import result_store

# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================

"""Code to compute the audio intensity for preprocessing.

Code that stores incoming arbitrary audio data, and then yields fixed window
sizes for processing (like computing the intensity.)

After initializing the object, add a block of data to the object, and then
pull fixed sized blocks of data with a given half_window_width, and separated
by window_step samples. Data is always X x num_features, where X can change from
add_data call to call, but num_features must not change. Do not reuse the object
because it has internal state from previous calls.

"""




class AudioIntensityStore(result_store.WindowedDataStore):
  """Process a window of data, calculating the mean-squared value.
  """

  def next_window(self):
    for win in super(AudioIntensityStore, self).next_window():
      yield np.mean(np.square(win))



class AudioLoudnessMick(result_store.WindowedDataStore):