Topic: Real-time 432hz Audio Auto-Pitching

I'd like to to real-time 432hz audio auto-pitching as described in this article
http://www.roelhollander.eu/en/432-tuni … c-players/

Adding this line of code in the AviSynth script file "should" work, but I just tried and haven't succeeded.
AssumeFPS(FrameRate*.981818, true)

How could I get this to work?

Is there another way to stretch the audio to get better audio quality?

This could be a cool feature of SVP.

Re: Real-time 432hz Audio Auto-Pitching

AssumeFPS not working in ffdShow Avisynth script. Because it time stretch function and can't be done separately from audio stream. So, you need use another way to time stretching. ReClock, for example.
I don't test it with your task. Maybe it is wrong way. You need try yourself.

3 (edited by Mystery 16-11-2015 08:10:24)

Re: Real-time 432hz Audio Auto-Pitching

The right command to use to alter the pitch without changing the frame rate is
TimeStretch(pitch=100.0 * 0.981818)

I tried ReClock and haven't seen any such option.

Re: Real-time 432hz Audio Auto-Pitching

Btw I found the solution to this: create an AVS file with this code, and open this instead of directly opening the video.

LoadPlugin("TimeStretch.dll")
SetMTMode(3,4)
DirectShowSource("Mamma Mia.mp4", audio=true, pixel_type="YV12", fps=23.976)
SetMTMode(2)
TimeStretchPlugin(pitch=100.0 * 0.981818)

Which requires this DLL
http://forum.doom9.org/showthread.php?p … ost1722472

And yeah this solution has nothing to do with SVP

Re: Real-time 432hz Audio Auto-Pitching

Mystery
I made demonstration how you can use ReClock to get 432 Hz audio from 440 Hz in realtime.
https://youtu.be/zD2gwTC__jE

Several rules.
1. You need to add custom resolution to your display. Different for each source framerate. In video shown example with 25 fps source.
2. You need to check if your audio really 440 Hz base frequiency. It is needed to use some frequency analyzer.
3. Slowdown can be applicable mainly for instrumental music but not for voice or sounds of nature. It this case sounds are real when pitch is 1.00x at source speed.

Calculations and explanations.
25 fps soucre. Integer mutipliers 2 and 3 gives numbers 50 and 75.
I take 75 Hz and slow down it with 432/440 ratio. I got 75*432/440 = 73,636 Hz.
I used NVIDIA control panel to add this custom resolution (and frequency) to one of my monitors.
I allow ReClock to use 3% slowdown. So I got new sample rate in ReClock for 44100 Hz audio: 43296 Hz.
Make some test with calculation real ratio: 43296 / 44100 = 0,981769 It is very close to yours 0,981818.

Post's attachments

432Hz_with_ReClock.jpg, 52.03 kb, 640 x 360
432Hz_with_ReClock.jpg 52.03 kb, 792 downloads since 2015-11-17 

Re: Real-time 432hz Audio Auto-Pitching

Intel HD 4000 doesn't allow custom resolutions above 60hz. Can't do this on a dual-graphics laptop.

Re: Real-time 432hz Audio Auto-Pitching

Mystery wrote:

Intel HD 4000 doesn't allow custom resolutions above 60hz.

Really?  I was under the impression that there was little difference architecturally between Ivy Bridge and Haswell's iGPU, and I've been running custom resolutions over 60Hz on my Pentium G3258 for a while now..

Re: Real-time 432hz Audio Auto-Pitching

The Radeon card would support it... if it wasn't dual-graphics

Re: Real-time 432hz Audio Auto-Pitching

The resample in ffdshow is different?

Post's attachments

ffdshow_resample.png, 18.13 kb, 554 x 473
ffdshow_resample.png 18.13 kb, 734 downloads since 2015-11-17 

Re: Real-time 432hz Audio Auto-Pitching

mashingan
Thank you. I will check it.

11 (edited by Mystery 18-11-2015 13:55:26)

Re: Real-time 432hz Audio Auto-Pitching

mashingan, I tried it. That didn't make any difference for me. Perhaps the audio isn't being processed by ffdshow? Adding "ffdshow Audio Decoder" in MPC-HC's external filters doesn't help.

And if it did, what about 48000hz sources?

Here's the AviSynth code that's working best so far

PluginPath=""
LoadPlugin(PluginPath+"ffms2.dll")
LoadPlugin(PluginPath+"TimeStretch.dll")
SetMTMode(3,4)
FFmpegSource2(source="Input.mp4", atrack=-1, cache=false, threads=1)
SetMTMode(2)
ResampleAudio(48000)
SemiTone = -0.3176665363342977
TimeStretchPlugin(pitch = 100.0 * pow(2.0, SemiTone / 12.0))

Which requires these 2 DLLs
http://avisynth.nl/index.php/FFmpegSource
http://forum.doom9.org/showthread.php?p … ost1722472

12 (edited by mashingan 18-11-2015 14:41:00)

Re: Real-time 432hz Audio Auto-Pitching

Mystery
Don't forget to enable the codecs in Codecs tabs

CMIIW, I think it actually matches to the input source and resample it to our target Hz.

Post's attachments

ffdshow_audio_enable.png, 32.21 kb, 554 x 473
ffdshow_audio_enable.png 32.21 kb, 699 downloads since 2015-11-18 

Re: Real-time 432hz Audio Auto-Pitching

mashingan
I checked Resample option in ffdShow Audio. Pitch is not corrected for me. I see only speed changes. Very little when change and back after some seconds after.
So. The pitch not changed form 440 Hz to 432 Hz. sad

Re: Real-time 432hz Audio Auto-Pitching

Is there a way to get the audio also processed through ffdshow when SVP is running its script, so that I can simply add the TimeStretch in there?

Re: Real-time 432hz Audio Auto-Pitching

MAG79 wrote:

mashingan
Pitch is not corrected for me. I see only speed changes.
So. The pitch not changed form 440 Hz to 432 Hz. sad

Yeah, I didn't really realized until you mentioned it.

I tried TimeStretch but ffdshow_source() only contains the video not the audio, so TimeStretch complains the clip has no audio.

While what I could think of is to use DirectShowSource to load audio only in complement to ffdshow_source(), I prefer to load it using ffdshow too as Mystery mentioned above.

16 (edited by Mystery 19-11-2015 03:55:57)

Re: Real-time 432hz Audio Auto-Pitching

With the above script, some videos play corrupted with SVP.
http://s20.postimg.org/ew5cth5cp/Player.jpg

If I disable SVP, then the image shows up fine. Until I re-open it again.

Any idea what could be causing this and how to avoid it?

What's also curious is that yesterday I only saw that issue a few times on the TV screen, while right now on my laptop screen it seems to show all videos as corrupt.

Edit: Adding "ConvertToYV12()" after FFmpegSource2 does solve the problem in "most" cases.

There is still occasional corrupt videos and occasional out of sync audio; where plugging into ffdshow directly would be a better option.

17 (edited by Nintendo Maniac 64 19-11-2015 07:42:44)

Re: Real-time 432hz Audio Auto-Pitching

Maybe in LAVfilters, try to disable all the output formats except YV12?

Re: Real-time 432hz Audio Auto-Pitching

Mystery
I just try Intel Custom Resolutions and Modes
So, I just now added 50 Hz mode at my monitor connected to Intel HD Graphics 4000.
I need some more time to google and to add fraction modes such as 23.976x2 * 0.981818 = 47,080 Hz.
It will be 440 to 432 Hz mode for 23,976 fps videos. wink

Re: Real-time 432hz Audio Auto-Pitching

Somehow I got 58.943 Hz at my monitor and 43312 / 44100 = 0.982131 pitch ratio.
It gives me 440 Hz * 0.982131 = 432,13 Hz wink

50 fps at the picture it is 2x smoothing after SVP.

Post's attachments

ReClock&Intel.jpg, 163.03 kb, 905 x 625
ReClock&Intel.jpg 163.03 kb, 693 downloads since 2015-11-19 

20 (edited by Mystery 20-11-2015 00:38:29)

Re: Real-time 432hz Audio Auto-Pitching

If I try to add 1366x768 50hz, I get the error "The custom resolution exceeds the maximum bandwidth capacity"

Dual-graphics are kind of a hardware hack, and hacking over hacks doesn't always work.

On a technical side, why isn't the audio being processed by ffdshow? It does have as much support for audio as it has for video, so why couldn't we process the audio in the exact same way as the video with SVP?

Re: Real-time 432hz Audio Auto-Pitching

Nintendo Maniac 64 wrote:

Maybe in LAVfilters, try to disable all the output formats except YV12?

I tried that and it didn't work.

Here's one video that fails
https://www.youtube.com/watch?v=Nwh3Kc-Nta0

Here are the streams I have downloaded

Video: MPEG4 Video (H264) 854x480 29.97fps 1082kbps [V: h264 main L3.1, yuv420p, 854x480, 1082 kb/s]
Audio: AAC 44100Hz stereo 253kbps [A: SoundHandler (aac lc, 44100 Hz, stereo, 253 kb/s)]

When playing through the AVS script, here's how MPC-HC sees the streams

Video: I420 854x480 29.97fps [V: rawvideo, yuv420p, 854x480]
Audio: IEEE Float 48000Hz stereo 3072kbps [A: pcm_f32le, 48000 Hz, 2 channels, fp32, 3072 kb/s]

Re: Real-time 432hz Audio Auto-Pitching

Mystery

Audio: IEEE Float

It is the issue. You need to disable float format since it is not supported by large number of audio cards.
MPC-HC - menu View - Options - Internal filters - Audio decoder - disable option "32-bit Floating-point" - OK - OK

23 (edited by Mystery 20-11-2015 05:19:23)

Re: Real-time 432hz Audio Auto-Pitching

It is already disabled. The problem is that AviSynth returns IEEE Float which must then be converted by the player. Not sure how to get AviSynth to return it as Int audio.

And I doubt this is the problem because this applies to every videos, and 96% of them play just fine.

Re: Real-time 432hz Audio Auto-Pitching

It is not avisynth. It is audio decoder. Looks like LAV Audio decoder is not used in your case. Used some another decoder with float output enabled. You need to change it.

25 (edited by Mystery 20-11-2015 05:51:41)

Re: Real-time 432hz Audio Auto-Pitching

It's also worth nothing that without SVP, it appears fine. and adding SVP into the mix is what corrupts it.

but perhaps the float audio doesn't help. Not sure how to change it.

On a side note, this setup is actually working pretty well with my software playing the videos one after the other and generating the scripts. Audio/video sync is holding pretty well... when using SVP3. I've been getting weird stuff going on when re-testing SVP4, and I don't want to test 2 new components at the same time. But if SVP starts lagging, then audio/video go off sync.

This also gives a more accurate pitch than any "change play speed" approach. I've tried the "play .981818 slower" approach both with AviSynth and with VLC, and in both cases, the pitch was higher. I also listened to both approaches side-by-side, and I can barely hear the quality loss resulting from the conversion **when using TimeStretch.dll instead of the built-in function and when first resampling to 48000hz**.