#! /usr/bin/env python
# -*- coding: utf-8 -*-

import hark
import numpy

class MyNode(hark.node.PythonNode):
    def __init__(self):
        super().__init__('INPUT', 'OUTPUT')

    def forward(self, **kwargs):
        # print('MyNode.forward(): kwargs={}'.format(kwargs))
        return {'OUTPUT': kwargs['INPUT']}

nch   = 8
freqs = numpy.logspace(0, 3, endpoint=False, num=nch+1, base=2)[:nch] * 440
phase = numpy.arange(16000) * freqs[:, None] / 16000 * 2 * numpy.pi
audio = numpy.sin(phase).astype(numpy.float32)

# reframing
input = numpy.lib.stride_tricks.sliding_window_view(audio, (nch, 512))[0, ::160]

mf = MyNode()

# print('INPUT: {}'.format(input))
output = mf(INPUT=input)
# print('OUTPUT: {}'.format(output))

print(output.OUTPUT)

# end of file