Skip to content

Commit

Permalink
Set default framelength to the usual long block 2048 samples
Browse files Browse the repository at this point in the history
  • Loading branch information
nils-werner committed Jun 1, 2016
1 parent 0a5add5 commit e3270ac
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def sig(N, random):
return numpy.random.rand(N)


@pytest.fixture(params=(1024, 2048))
@pytest.fixture(params=(256, 1024, 2048))
def framelength(request):
return request.param

Expand Down
8 changes: 4 additions & 4 deletions mdct/fast/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def mdct(
if transforms is None:
transforms = transforms_default

kwargs.setdefault('framelength', 1024)
kwargs.setdefault('framelength', 2048)

if not odd:
return stft.spectrogram(
Expand Down Expand Up @@ -106,7 +106,7 @@ def imdct(
if transforms is None:
transforms = transforms_default

kwargs.setdefault('framelength', 1024)
kwargs.setdefault('framelength', 2048)

if not odd:
return stft.ispectrogram(
Expand Down Expand Up @@ -160,7 +160,7 @@ def mdst(
if transforms is None:
transforms = transforms_default

kwargs.setdefault('framelength', 1024)
kwargs.setdefault('framelength', 2048)

if not odd:
return stft.spectrogram(
Expand Down Expand Up @@ -214,7 +214,7 @@ def imdst(
if transforms is None:
transforms = transforms_default

kwargs.setdefault('framelength', 1024)
kwargs.setdefault('framelength', 2048)

if not odd:
return stft.ispectrogram(
Expand Down

2 comments on commit e3270ac

@arijit17
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Nils:

Thanks for the Python MDCT :-)

I installed, and tried:
import mdct
spec = mdct.mdct(signal)
output = mdct.imdct(spec)
All works!

BUT:
How do I change the window shapes? For example, I want to try out different beta for the KBD windows.

Cheers,
Arijit

@nils-werner
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can pass in both numpy arrays and callables as the window parameter.

For example a callable with a beta parameter set. The appropriate windowlength will be set during the transform:

import functools
import numpy
import mdct

signal = numpy.random.rand(10000)

spec = mdct.mdct(
    signal,
    window=functools.partial(mdct.windows.kaiser_derived, beta=2)
)
output = mdct.imdct(
    spec,
    window=functools.partial(mdct.windows.kaiser_derived, beta=2)
)

or a numpy array of fixed length, also with the beta parameter set. The framelength needs to be known beforehand.

import functools
import numpy
import mdct

signal = numpy.random.rand(10000)

window = mdct.windows.kaiser_derived(2048, beta=2)
spec = mdct.mdct(
    signal,
    window=window,
    framelength=2048,
)
output = mdct.imdct(
    spec,
    window=window,
    framelength=2048,
)

For the future, please do not comment on individual commits with usuage questions. Instead you should

  • open an issue on the issue tracker (although excessive questions on issue trackers are considered bad practice, too) or
  • ask a question on Stack Overflow

Please sign in to comment.