Log in

View Full Version : Another flexible and extensible way of multi channel audio encoding using Avisynth.


Pages : 1 2 [3] 4

dimzon
8th December 2005, 14:44
BePipe.exe --script "WavSource(^c:\input.wav^)" | "C:\Program Files\FFMpeg\ffmpeg.exe" -i - -ab 256 "E:\output.ac3"

try
"C:\Program Files\FFMpeg\ffmpeg.exe" -i - -ab 256 "E:\output.ac3" < c:\input.wav

stephanV
8th December 2005, 16:58
mmh why we have id3 support in some lossless encoders in this case ?
Because they didn't bother to make their own? :)

I know at least the wavpack encoder still supports writing tags (but maybe they are APE, not ID3) though, for other CLI encoders I'm not sure. But this doesn't make the ID3 tag writing capability of BeSweet still a major advantage.

dimzon
9th December 2005, 10:26
BeHappy is now hosted on www.gotdotnet.com !
Check my signature

tebasuna51
9th December 2005, 18:15
-In previous post I use a matrix copied from source code of BS_Downmix plugin for BeSweet ( http://besweet.notrace.dk/plug-ins.htm ), used until BeSweet v1.5b19.
There are a newest, more efficient, matrix in http://forum.doom9.org/showthread.php?t=57988 used, I think, by Midas Azid 1.9 and/or BeSweet v1.5b20.

Then I must correct the coefficients in my function "Downmix dpl II"
a = last
f = GetChannel(a, 1, 2)
c = GetChannel(a, 3)
sl = GetChannel(a, 5)
sr = GetChannel(a, 6)
l = MixAudio(sl, sr, -0.2818, -0.1627) # -0.2222, -0.2222 for dpl (I)
l = MixAudio(l, c, 1.0, 0.2301)
r = MixAudio(sl, sr, 0.1627, 0.2818) # 0.2222, 0.2222 for dpl (I)
r = MixAudio(r, c, 1.0, 0.2301)
st = MergeChannels(l, r)
MixAudio(f, st, 0.3254, 1.0).Normalize()
You can use Normalize() for 100% or Normalize(0.95) for 95%...

- About methods in http://forum.doom9.org/showthread.php?t=103466 or http://md2.boerde.de/scharfi/

1) Now "Downmix dpl II" is a normalized version (to avoid clipping problems in int audio formats) of "function dpl2" (works with float audio format)

2) The "function dpl" is intended for sources 3/1 (4 input channels). For 3/2 you can use "Downmix dpl II" changing the coefficients in #comments.

dimzon
9th December 2005, 18:24
@tebasuna51
How about "Simple Stereo" downmix mode?
Thanx!

tebasuna51
10th December 2005, 04:43
Downmix to stereo is not critical because there aren't a dpl decoder involved. You can use also the LFE channel (not recommended for Dolby for dpl I/II).
A generic downmix may be:
FL' = FL + cc*C + ce*LFE + cs*SL
RL' = RL + cc*C + ce*LFE + cs*RL
These coefficients can vary with source type and users preferences. A decoder like azid have parameters to select these values.

For 6 independents channels may be:
FL' = FL + 0.7071*C + 0.7071*LFE + SL
RL' = RL + 0.7071*C + 0.7071*LFE + RL

And normalized:
FL' = 0.2929*FL + 0.2071*C + 0.2071*LFE + 0.2929SL
RL' = 0.2929*RL + 0.2071*C + 0.2071*LFE + 0.2929RL

Then "Downmix to stereo":
a = last
f = GetChannel(a, 1, 2)
c = GetChannel(a, 3)
e = GetChannel(a, 4)
sl = GetChannel(a, 5)
sr = GetChannel(a, 6)
l = MixAudio(sl, c, 0.2929, 0.2071)
l = MixAudio(l, e, 1.0, 0.2071)
r = MixAudio(sr, c, 0.2929, 0.2071)
r = MixAudio(r, e, 1.0, 0.2071)
st = MergeChannels(l, r)
MixAudio(f, st, 0.2929, 1.0).Normalize()
Edited: r = MixAudio(sr, e, 1.0, 0.2071) must be
r = MixAudio(r, e, 1.0, 0.2071).
Thanks MiCK76.

tebasuna51
10th December 2005, 14:02
- Mp3 encoder
Tested the Lame.exe (+ lame_enc.dll, in habitual package), and works fine with BeHappy with:
Arguments: - [-parameters ...] "{0}"
The first '-' make to Lame accept, by standard input, the audio stream send by BeHappy.
I think all requeriment about mp3 are covered by this standard encoder.

- Ac3 encoder
Tested ffmpeg.exe (CVS_2005-09-09) to encode ac3 files with:
Arguments: -i - -ab 448 "{0}"
AVS Script: 6==Audiochannels(last)?GetChannel(last,1,3,2,5,6,4):last

The only parameter allowed, AFAIK, is -ab 'bitrate', is very limited but, at last, we have the same than BeSweet-ac3enc.

The besweet seems to be the audio encoding back end, where include the AC3 and AAC supports. So we seem to be unable to expect more than what the besweet provides currently.
My initial idea was importing existing excellent tools such as johnman's WW which is based on the wav, or at least 6 mono wave splitter mentioned in the first post to support existing(OLD fashioned) encoder such as surcode or softencode(it can read almost any formats even raw).
To use SoftEncode (I don't know Surcode) we need:
- Write a .ini file with the parameters. Possible with AviSynth internal plugins WriteFileStart/WriteFileEnd.
- Write 6 mono wav with the channels. The mentioned 6 mono wave splitter. (?)
- Send the job to SoftEncode. (?)

- General Note
For the future we can think add a new button 'Configure' to open a new window, specific for each encoder/decoder, to capture the parameters to construct the Arguments for Lame, the ini file for Softencode, ...

Rockaria
10th December 2005, 16:41
The besweet not being the backend is what I admitted already. I just read some info from videohelp but had no time to (fully) test all the backends.

Surecode expects 6 mono wavs and 6ch wav/6 mono wavs/ raw is allowed for softencode(it also has the batch mode).
Whether it accepts the parameter from any formats or not(I doubt surecode), if we have to launch the application and can use it's own profiles(the worst thing is the disk space usage of the temporary wav files), the integration is at it's least or almost nothing.

I thought that this methodology or system includes all the existing capabilitis and tools(manual/automation), which does not need to be neat/unified sacrificing the flexibility.
The ffdshow(or dsfilters, grf) portion is too big to abandon, to me.

So the (new) BeHappy has the 'user defined function' capability now?

tebasuna51
11th December 2005, 00:00
Sorry Rockaria, I don't understand very well your comment about SoftEncode because my bad english.
I talk, of course, about batch mode. From the SoftEncode Help:

"Command Line Operation of Soft Encode

Soft Encode provides the ability to be run from completely command line based commands. The Soft Encode main screen will never have to be open to run these commands. The syntax is as follows:

Sftencdd.exe -A -P <ini_file> -o <out_file> -L <left> -R <right> -C <center> -l <sleft> -r <sright> -e <LFE>

-A auto switch, this must be set for it to process the command line
-P specifies the full path and file name of an ini file that has overrides for the AC3 settings ..."

Then:
- The job work without more interaction of the user.
- The ini_file control all possible parameters of the encoder.
- In batch mode only mono wav are accepted
- The main problem, like you say, is the necessity of create these 6 mono wav.

About your last comment:
"So the (new) BeHappy has the 'user defined function' capability now?"
May be the word 'function' is too ambitious and must use the word 'macro'.

Rockaria
11th December 2005, 00:42
"So the (new) BeHappy has the 'user defined function' capability now?"
May be the word 'function' is too ambitious and must use the word 'macro'.The user function is clearly defined in the avisynth's manual and I clearly agree with it's correct use of the terms.
The 'macro' is used for 'something to be expanded to code blocks before the compilation. So preprocessors has this behaviors usually.

The major advantage of the avisynth is treating the stream instead of the resource-taking file-io between the processors. Even though it does not require the user interface, if it asks 6 mono waves for the input, it has very loose integration.
I assume the surecode behave similar, which begs somebody's clarification.

And one(actually two) of my questions is left unanswered : the last and the first.

My last comment : The language would be no problem if we try to use the international accent and can understand more than what is said.

Rockaria
12th December 2005, 02:34
I had to find a way to insert some customized script block in the BeHappy.
If not allowed the avs save or the user function editor yet, the Import() is the only but effective way to include the unsupported complicated scripts and connect to BeHappy, keeping the gui interface as neat as it is.

We can put user functions there and can define DSPs for the each function which returns a clip. So some issue mentioned before(joining, mixing, splitting...) is covered with this way.
But it is still somewhat inconvenient with the file path, in which case the PathCopyEx.msi mentioned @#1 would be useful.

As I mentioned in other thread, any plugins installed in the avisynth's plugin folder do not need to be loaded explicitly.
Also we can omit the clip variable reference when working on the last defined clip, identified as the global variable last
Using Amplify() will be useful if we have a ReplayGain dB data from other scanning tools such as foobar2k.

[edit]
O.K., I found the DSP editor has the multi line text editing capability. The predefined simple DSPs forced me to overlook it's existance. It turned out rather proper for the profile(configuraions) management use.
The confusion is initially caused by some predefined DSP functions not using the variable(--> last) forcing the strict variable naming convention for the clips between the DSPs, the scope of which can be managed automatically inside of the user functions.
So if used in a macro style, the variables need to be strictly managed, which is not desirable forcing me to deny the possibility of the adoption.
But if used in a user function style, we can choose two ways to define:
. define as a DSP in the BeHappy. if enabled, can be called from anywhere.
. define in groups of avs. if imported once anywhere, can be called from anywhere

Overall, it depends on the tastes. You can choose. Nothing is wrong or right if used correctly. /slience.

dimzon
12th December 2005, 11:47
Hi!
Does whe really need LoadPlugin ability? Maybe intslling plugins in the avisynth's plugin folder is better way?
You can use *.avsi files into avisynth's plugin folder to provide you custom functons...

dimzon
12th December 2005, 11:51
- General Note
For the future we can think add a new button 'Configure' to open a new window, specific for each encoder/decoder, to capture the parameters to construct the Arguments for Lame...
It will be added later. I want to create extensible API to allow multiple GUI plugins for DSP/Encoder configuration :)

dimzon
12th December 2005, 11:53
But if used in a user function style, we can choose two ways to define:
. define as a DSP in the BeHappy. if enabled, can be called from anywhere.
. define in groups of avs. if imported once anywhere, can be called from anywhere
Does You really need to define custom function in one DSP to be able to call it from another? Can you post example?

Rockaria
12th December 2005, 16:49
It's rather a basic language/pattern concept. A good architecture prevents any possible mistakes or self-restrictions.

[a possible mistake in macro use]

a1=clip1 // a global clip to join later
a2=clip2 // a global clp to join later but need some preprocessing
<dsp1>
a1=last
fl=..
<dsp 2>
a2=getchannel...
...
c=a1+a2
--

In this case, we need to lookup every DSPs used to verify if the variables are used correctly, other than that a strict process structure or variable naming convention is required, yeah restrictions very opposite to flexibility.

[a very simple user function usage]

ta=duration(clipa) //inside of DSP1
tb=duration(clipb) //inside of DSP2
function duration(clip){return frames/framerate} // defined in a UserFunctions1 DSP(or in a avs form to be imported) possibly with other related functions

Also any variable names can be used freely inside of the functions(at least it's a common sense).

[a possible DSPs use as profile management]

<nero 6 48000 ReplayGain Join>
<nero 7 48000 MaxNorm Single>
...
SSRC(48000).Normalize()
GetChannel(2,3,1,6,4,5)
..
<oggenc 48000 MaxNorm Single>
...
GetChannel(1,3,2,5,6,4)
..
<AC3 ffmpeg 48000 MaxNorm Single>
...
GetChannel(1,3,2,5,6,4)
..
<MIX User Functions>
function DPL II-1{.. return clip}
function DPL II-2{.....}
function UPMIX-1{...}
...
<Common utils>
...

[save to avs & launcherscript]
. I have experienced a trouble in the file path, in which case I had no option to check if the script is generated correctly.
. the gui log message is not as detailed as dosbox or avs preview in MPC.
. cannot preview how it sounds before the long encoding work
. cannot try test-tuning on the fly.
. cannot integrate to other avisynth clients such as MakeAVIS, avs2avi or avs2wav. Any special reason to restrict this?

[other things]
. I guess if placed in a local folder (together with avisynth.dll), the avis plugins need not be loaded explicitly also.
. the configuration xml seems better to be placed in the local folder.
....
......
........

But again, it depends on the tastes. BeHappy is extremly flexible as I said before.

dimzon
12th December 2005, 20:16
@Rockaria
I asking You about real-life sample to approve You needs to to define custom function in one DSP to be able to call it from another

the configuration xml seems better to be placed in the local folder
It's really BAD bcz only Administrators can write to Program Files folder!

tebasuna51
12th December 2005, 21:13
I edited a previous post:

A problem with BeSweet, resample a multichannel wav with ssrc, works fine with "ssrc 5.1 48000":
#a = last
#f = GetChannel(a, 1, 2).SSRC(48000)
#c = GetChannel(a, 3, 4).SSRC(48000)
#s = GetChannel(a, 5, 6).SSRC(48000)
#MergeChannels(f, c, s)
#EDITED: the precedent lines works but is only necessary:
SSRC(48000)

Because the internal AviSynth plugin SSRC() works with multichannel streams, like Rockaria say me in another thread.
Sorry, I'm really newbie in AviSynth.

Rockaria
12th December 2005, 21:33
@Rockaria
I asking You about real-life sample to approve You needs to to define custom function in one DSP to be able to call it from another
me no junior, nor even senior /retired.

Closure! Not compliant to my philosophical standard!

Unless explained reasonably why it cannot be backward compatible, which is where this system is from, I also respectfully decline using my name with the project together, while you can continue the exploration with the idea anywhere.

I have been just trying to introduce and help anybody for the full realization of this potentials under the GPL spirit, despite the initial noise.
But if most of the reasonable checkpoints are skipped, ignored and left unanswered, it's no more a cooperational job, which is why it cannot be approved compliant.

And no more dead horse please. Thanks.

dimzon
13th December 2005, 09:22
@Rockaria
please do not make a drama
Current BeHappy status is not even alpha - it's really planning. I have no time to work on BeHappy hard right now but I'm collecting user requests and analyzing them:
- Is it really requred? Can same effect be achived using current abilities?
- How to implement this

If I harm You - please sorry - my poor english is a reason...

Unless explained reasonably why it cannot be backward compatible, which is where this system is from...
Can You explain me what does it means?

Rockaria
13th December 2005, 11:06
No drama to make, your 'approval' & 'real example' was the drama. And the BeHappy doesn't need to be dramatically BIG.
No, it's already there, you don't have to change anything, if you read carefully. Just take away those misleading predefined DSPs and change the title to Profiles instead of DSPs if you agree.

I've told you the need for 'avs save' at least three times. Were you there listening? Read again & get ready to discuss/answer all the checkpoints before making any new post just to change the focus.

Even though I stopped the coding years ago, I've been doing the architect work around a decade, seeing through the architecture and resources where includes the human factor also.
So there should have been no waste at all if we met in the real world.

Anyway, whether you understand or not, I seem to have discussed all the crucial topics enough already.
Another thing is, start from the next version in a new thread. This thread has got ruined too much from the beginning.

/bye

dimzon
13th December 2005, 11:32
No drama to make, your 'approval' & 'real example' was the drama.
I just can't believe You need such functionality in real life, really! And I don't want to harm You!

No, it's already there, you don't have to change anything, if you read carefully.
The current code is a little ugly. I want to simplify and refactor it before continue!

Just take away those misleading predefined DSPs and change the title to Profiles instead of DSPs if you agree.
IMHO profile is set of DSP - not simple "DSP". Maybe I'm wrong?

I've told you the need for 'avs save' at least three times. Were you there listening?
Hey! I don't say NO on it is'nt it? It will be implemented. I'm realy busy now (my workday duration is 10-12 hrs - not a 8) and sometimes I need some time to make a design before answer!

/bye

Rockaria
13th December 2005, 13:21
I just can't believe You need such functionality in real life, really! And I don't want to harm You!
Yeah you don't really need the float in your real NORMAL life.
But I agree. go ahead. I don't really want to HURT your servicemanship. ;)

IMHO profile is set of DSP - not simple "DSP". Maybe I'm wrong?That's right, unlike the initial definition. But later, I found it has multiline editor, turned out better suitted for each profile containing all the DSP function(inluding user function) calls. So no more need for the seperate profile management. You will find the macro insertion is not that flexible as function calls in many respects. It's language/pattern BASIC not the SPECIAL functionality.

Hey! I don't say NO on it is'nt it? It will be implemented.Good to know that. But a very looooooose answer or no answer...hmm..
But no problem. It's a test purpose. I am doing almost no transcoding in my real life.

/Progress in the usability with your BeHappy

tebasuna51
13th December 2005, 17:10
@Rockaria you must be more patient with us. With a Avisynth newbie like me, and with the busy Dimzon.
I'm sure Dimzon don't want offend you with the word 'approval'.
I'm not offended by your 'senior/retired' (I'm retired).
And the language is another handicap, at last for me. (What mean 'dead horse'?)

I agree with your comments about 'macro style', then "Downmix dpl II" can be written, to avoid problems with variable names, like this:
function DPL_II(clip a) {
Assert(a.Audiochannels == 6, "DPL_II: audio input must have 6 channels")
f = GetChannel(a, 1, 2)
c = GetChannel(a, 3)
sl = GetChannel(a, 5)
sr = GetChannel(a, 6)
l = MixAudio(sl, sr, -0.2818, -0.1627)
l = MixAudio(l, c, 1.0, 0.2301)
r = MixAudio(sl, sr, 0.1627, 0.2818)
r = MixAudio(r, c, 1.0, 0.2301)
st = MergeChannels(l, r)
return MixAudio(f, st, 0.3254, 1.0).Normalize()
}
DPL_II # Execute now
Or without the last line for only define the function, and another DSP to execute. At the moment, with simple flow like Decoder -> DSP's -> Encoder, I canīt imagine a situation to call twice DPL_II.

For the future we can think a tool 'Construct AVS' like a precompiler to detect the used functions and include the definitions needed, maybe from external libraries (for easy update). But, like Dimzon, I need a real problem to imagine a solution.

Of course the 'Save avs' button is very interesting

dimzon
13th December 2005, 17:50
I agree with your comments about 'macro style', then "Downmix dpl II" can be written, to avoid problems with variable names, like this:
function DPL_II(clip a) {
Assert(a.Audiochannels == 6, "DPL_II: audio input must have 6 channels")
f = GetChannel(a, 1, 2)
c = GetChannel(a, 3)
sl = GetChannel(a, 5)
sr = GetChannel(a, 6)
l = MixAudio(sl, sr, -0.2818, -0.1627)
l = MixAudio(l, c, 1.0, 0.2301)
r = MixAudio(sl, sr, 0.1627, 0.2818)
r = MixAudio(r, c, 1.0, 0.2301)
st = MergeChannels(l, r)
return MixAudio(f, st, 0.3254, 1.0).Normalize()
}
DPL_II # Execute now
Or without the last line for only define the function, and another DSP to execute. At the moment, with simple flow like Decoder -> DSP's -> Encoder, I canīt imagine a situation to call twice DPL_II.

For the future we can think a tool 'Construct AVS' like a precompiler to detect the used functions and include the definitions needed, maybe from external libraries (for easy update). But, like Dimzon, I need a real problem to imagine a solution.

Of course the 'Save avs' button is very interesting
1) Why not just place DPL_II to dpl2.avsi into AviSynth plugin folder
2) I can implement additional macro to prevent variablename conflict:
function DPL_II_{0}(clip a) {
...
}
DPL_II_{0} # Execute now
will be transofmed into something like this (in final AVS)
function DPL_II_B4137A36CBAA41E0841208386EE7A408(clip a) {
...
}
DPL_II_B4137A36CBAA41E0841208386EE7A408 # Execute now
where B4137A36CBAA41E0841208386EE7A408 will be unique per DSP (System.Guid.NewGuid().ToString("N"))
or you can still use functionless style:
a{0} = last
f{0} = GetChannel(a{0}, 1, 2)
c{0} = GetChannel(a{0}, 3)
e{0} = GetChannel(a{0}, 4)
sl{0} = GetChannel(a{0}, 5)
sr{0} = GetChannel(a{0}, 6)
l{0} = MixAudio(sl{0}, c{0}, 0.2929, 0.2071)
l{0} = MixAudio(l{0}, e{0}, 1.0, 0.2071)
r{0} = MixAudio(sr{0}, c{0}, 0.2929, 0.2071)
r{0} = MixAudio(sr{0}, e{0}, 1.0, 0.2071)
st{0} = MergeChannels(l{0}, r{0})
MixAudio(f{0}, st{0}, 0.2929, 1.0).Normalize()

dimzon
13th December 2005, 18:13
At the moment, with simple flow like Decoder -> DSP's -> Encoder, I canīt imagine a situation to call twice DPL_II.
Agreed! I can't imaginate whe need such ability in real transcoding process at all! This is a reason for 'approval' word - I just need a real AVS sample!

And some words about BeHappy concepts:
BeHappy is not all-in-one universal audio processor. Don't bother me about audio concatenation via GUI. I'm not evil but I don't need such functionality myself and I have not time to design and code such GUI part (I prefer to spent time for AviSynth audio plugin development - I really need dynamic range compression and reverb). You can write such AVS manualy and load it into BeHappy via WavSource or Import. Or You can write such GUI code Yourself (BeHappy is GPL!) But it's really rare case, is'nt it?
BeHappy is BeLight/BeSweet replacement/concurrent - primary usage is audio track transcoding during DVD-Backup process.

future BeHappy vision/anonce/plans

Complete code refactoring and GUI redesign
Job control like in MeGUI
Import/Export Source/DSP/Encoder functionality
Large set of predefined DSP - to cover current BeSweet functionality
AVS Export
AVS Preview (Prelisten :D )
GUI plugins for LAME/OggVorbis etc

Rockaria
13th December 2005, 18:57
@tebasuna51 :
The communication rule #x : at least nod or give your eyes to express you are listening.
When it requires the repetition more than two, it really becomes a matter of patience, normally, isn't it?. Retired from the thread or whatever, I am not offended by any case either..
Onto a clip, you will seldomely find the case calling the same function twice. But onto several clips, it wouldn't be a rare case. Or already self-restricting the number of clips to one? Even if it is used once, there are still several advantages of the function style.
Because the function call is so streightforward, it would be better using the current DSPs as PROFILEs(like 'nero aac v6 48000 single') and include complete DSP functions there. It's a little shift of the scheme.

BTW, if you get an email from the retired company three years ago, asking to return some document debated on the day three month's before the retirement, the email is a dead horse, AFAIK.

I can't imaginate whe need such ability in real transcoding process at all! This is a reason for 'approval' word - I just need a real AVS sample!
Again, It's your limitation requiring other's support not your approval! Or don't use the user functions in your program at all! It's patented. :confused:
No more dead horse please.

dimzon
13th December 2005, 19:23
Or already self-restricting the number of clips to one?
Yes! Just remember 20/80 rule from MSF aka Pareto principle (http://en.wikipedia.org/wiki/Pareto_principle)! BeHappy goal is not to use ALL AviSynth power (You can write AVS manualy in complex cases) but provide nice user-friendly GUI for common tasks. There are 2 reason of this:

I have no time to implement functionality not interested for me.
It's impossible to use all 100% AviSynth power via GUI - just remember programming languages - you still need to write code!

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.


Because the function call is so streightforward, it would be better using the current DSPs as PROFILEs(like 'nero aac v6 48000 single') and include complete DSP functions there. It's a little shift of the scheme.
Ok, I will think about it!

Rockaria
13th December 2005, 19:38
Yes! Just remember 20/80 rule from MSF! BeHappy goal is not to use ALL AviSynth power (You can write AVS manualy in complex cases) but provide nice user-friendly GUI for common tasks. There are 2 reason of this:

I have no time to implement functionality not interested for me.
It's impossible to use all 100% AviSynth power via GUI - just remember programming languages - you still need to write code!

..
Ok, I will think about it!OK. that is expected by my common sense.
As far as it is backward compatible(avs export) and provide the minimum flexibility for multi clip use by the architecture, as I said before, it would be a smooth & complete job.
Everybody is busy and it's already end of year...
/next year

dimzon
16th December 2005, 17:47
new version GUI prototype
http://img371.imageshack.us/img371/4041/bh06sd.gif
http://img269.imageshack.us/img269/4301/bh16pl.gif

Any comments?

tebasuna51
19th December 2005, 04:46
Very nice job, Dimzon. For me is enough like GUI at the moment.

I found a bug in wav output and I send you a pm about this.

MiCK76
19th December 2005, 15:13
hi everyone and kudos to dimzon for the excellent work.

i found the avisynth downmix functions not working properly for me (they gave me the "speech" from the central channel only in the left channel in simple stereo downmix for example) so i've rewritten them this way and i found the result correct:

function DPL_II(clip a) {
fl = GetChannel(a, 1)
fr = GetChannel(a, 2)
c = GetChannel(a, 3)
sl = GetChannel(a, 5)
sr = GetChannel(a, 6)
ssl = MixAudio(sl, sr, 0.2818, 0.1627).Amplify(-1.0)
fl_c = MixAudio(fl, c, 0.3254, 0.2301)
ssr = MixAudio(sl, sr, 0.1627, 0.2818)
fr_c = MixAudio(fr, c, 0.3254, 0.2301)
l = MixAudio(ssl, fl_c, 1.0, 1.0)
r = MixAudio(ssr, fr_c, 1.0, 1.0)
return MergeChannels(l, r).Normalize()
}



function SimpleStereo(clip a) {
fl = GetChannel(a, 1)
fr = GetChannel(a, 2)
c = GetChannel(a, 3)
lfe = GetChannel(a, 4)
sl = GetChannel(a, 5)
sr = GetChannel(a, 6)
l_sl = MixAudio(fl, sl, 0.2929, 0.2929)
c_lfe = MixAudio(lfe, c, 0.2071, 0.2071)
r_sr = MixAudio(fr, sr, 0.2929, 0.2929)
l = MixAudio(l_sl, c_lfe, 1.0, 1.0)
r = MixAudio(r_sr, c_lfe, 1.0, 1.0)
return MergeChannels(l, r).Normalize()
}


dont know why the remapping didnt work correctly with the original syntax, but this one is correct for me

bye

MiCK76
19th December 2005, 15:17
same way i've written also a DPL II with LFE channel downmix (i know it's not suggested by Dolby, but if you dont care....) ;)

function DPL_II_LFE(clip a) {
fl = GetChannel(a, 1)
fr = GetChannel(a, 2)
c = GetChannel(a, 3)
lfe = GetChannel(a, 4)
sl = GetChannel(a, 5)
sr = GetChannel(a, 6)
c_lfe = MixAudio(c, lfe, 0.1871, 0.1870)
fl_c_lfe = MixAudio(fl, c_lfe, 0.2645, 1.0)
fr_c_lfe = MixAudio(fr, c_lfe, 0.2645, 1.0)
ssl = MixAudio(sl, sr, 0.2291, 0.1323).Amplify(-1.0)
ssr = MixAudio(sl, sr, 0.1323, 0.2291)
l = MixAudio(ssl, fl_c_lfe, 1.0, 1.0)
r = MixAudio(ssr, fr_c_lfe, 1.0, 1.0)
return MergeChannels(l, r).Normalize()
}

tebasuna51
19th December 2005, 20:28
@MICK76
I don't know what is the problem. The two syntax are equivalent and work for me.
May be AviSynth version? I'm work with v2.5.5.0.

MiCK76
20th December 2005, 16:10
@MICK76
I don't know what is the problem. The two syntax are equivalent and work for me.
May be AviSynth version? I'm work with v2.5.5.0.

yes i know, they "should" be equivalent, but they're not for me...
i use avisynth 2.5.5 too, and i tried the simpledownmix exactly how you wrote it and gave me the central channel only in the left one, while rewritten in this way gave me correct downmix..

dont know if MixAudio function mess up working with multichannel tracks like in your MixAudio(f, st, 0.3254, 1.0) where both f and st are stereo and not mono..

same is for MixAudio(sl, sr, -0.2818, -0.1627)...are you sure is correct? i mean in avisynth documentation MixAudio doesn't seem to support negative scale values, while Amplify() does (that's why i use MixAudio(sl, sr, 0.2818, 0.1627).Amplify(-1.0)).

anyway your work is great and kudos to you.
thx for pointing at the correct dplII downmix matrices
bye

MiCK76
20th December 2005, 18:27
ops i found what was wrong in your simple stereo function syntax that gave me that error:

a=last
f = GetChannel(a, 1, 2)
c = GetChannel(a, 3)
e = GetChannel(a, 4)
sl = GetChannel(a, 5)
sr = GetChannel(a, 6)
l = MixAudio(sl, c, 0.2929, 0.2071)
l = MixAudio(l, e, 1.0, 0.2071)
r = MixAudio(sr, c, 0.2929, 0.2071)
######################
r = MixAudio(sr, e, 1.0, 0.2071) # <-- here it is
###################### correct one: r = MixAudio(r, e, 1.0, 0.2071)
st = MergeChannels(l, r)
MixAudio(f, st, 0.2929, 1.0).Normalize()

just so easy...dont know why i didnt notice it before...
anyway it remains the issue of the negative
scale values in MixAudio: Amplify(-1.0) is the supposed
correct way to do it imho.

MiCK76
20th December 2005, 18:31
i tried encoding the same small clip with your syntax (both dplII and simple stereo mode) and mine, both with lame and oggenc2, and i get different
file size results (just 1-2 kB on a 270 kB end result file), but if the scripts
are equivalent why does it happen????? i really dont know

strange things happen on these damn'd machines ;)

tebasuna51
21st December 2005, 02:12
@ Thanks MiCK76. You are right with the error in "Downmix to stereo" in my post #106 (edited). It remain in the #124 by Dimzon

Inside BeHappy I use a correct version and work for me. Sorry.

About:
same is for MixAudio(sl, sr, -0.2818, -0.1627)...are you sure is correct? i mean in avisynth documentation MixAudio doesn't seem to support negative scale values, while Amplify() does (that's why i use MixAudio(sl, sr, 0.2818, 0.1627).Amplify(-1.0)).
In my first test I use Amplify(-1.0), after I try with negative values and work also. The differences between this two methods are below 0.0002 (-73.41 dB).

Using coefficients with four digits we can expect this differences. If the coefficients are applied in distinct order the result must be different.

dimzon
21st December 2005, 19:36
Does anybody know how to apply trim() to audio to mimic BeSweet's --split switch? Maybe creating 16х16 1000fps video and AudioDub it before trim? Can anybody check?

dimzon
22nd December 2005, 14:23
- complete rewritten from scratch
- new GUI layout/feel
- export to AVS functionality
- job control
- ready to external plugins & extension's (look @ NicAudio.extension)
- encoding is not working yet!

http://img376.imageshack.us/img376/2885/untitled34gu.gif

http://www.mytempdir.com/336548

redfordxx
22nd December 2005, 14:38
Does anybody know how to apply trim() to audio to mimic BeSweet's --split switch? Maybe creating 16х16 1000fps video and AudioDub it before trim? Can anybody check?I can only say what I did: I do not say it is the best. The input was 5.1 wav. I made some clip (as you write) with audio_clip_fps=2*movie_fps. Then IIRC trim(0,movie_frame_count*2-1). But not sure about the -1.



I think beHappy would be nice for me, if only there was a WMA 5.1 decoder for AviSynth;-).
Joking, I will have other sources than wma too...

dimzon
22nd December 2005, 19:32
External plugin in action :)
http://img461.imageshack.us/img461/2629/untitled48gw.gif

<?xml version="1.0"?>
<BeHappy.Extension
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://workspaces.gotdotnet.com/behappy">
<AudioEncoder UniqueID="970151FD-EB11-4c93-BA3D-481C5976CF66">
<Plugin>
<OggVorbisEncoder
Type="BeHappy.OggVorbis.Encoder.Extension.OggVorbisEncoder, BeHappy.OggVorbis.Encoder.Extension"/>
</Plugin>
</AudioEncoder>
</BeHappy.Extension>

dimzon
23rd December 2005, 11:36
http://www.mytempdir.com/338321
Encoding not working yet!
Sample extensions:
NicAudio.extension - simplest extension sample
DownMix.extension - configureable extension
BeHappy.OggVorbis.Encoder.extension - configureable extension with it's own GUI

Generated script:
########################################
#Created by BeHappy v1.0.2183.23933
#Creation timestamp: 23.12.2005 13:19:48
########################################
#Source FileName:C:\1 1 1.m4a
#Target FileName:C:\1 1 1.ogg
########################################

########################################
# [Source: DirectShowSource]
########################################
DirectShowSource("C:\1 1 1.m4a")

########################################
# [DSP: Downmix - DPL II (LFE)]
########################################

# Store clip in variable
c64e934d9334b4d9f8ae9e16fe4aa5498=last
# Define transformation function


# DPL II (LFE)
function f64e934d9334b4d9f8ae9e16fe4aa5498(clip a) {
fl = GetChannel(a, 1)
fr = GetChannel(a, 2)
c = GetChannel(a, 3)
lfe = GetChannel(a, 4)
sl = GetChannel(a, 5)
sr = GetChannel(a, 6)
c_lfe = MixAudio(c, lfe, 0.1871, 0.1870)
fl_c_lfe = MixAudio(fl, c_lfe, 0.2645, 1.0)
fr_c_lfe = MixAudio(fr, c_lfe, 0.2645, 1.0)
ssl = MixAudio(sl, sr, 0.2291, 0.1323).Amplify(-1.0)
ssr = MixAudio(sl, sr, 0.1323, 0.2291)
l = MixAudio(ssl, fl_c_lfe, 1.0, 1.0)
r = MixAudio(ssr, fr_c_lfe, 1.0, 1.0)
return MergeChannels(l, r)
}

# Call function
f64e934d9334b4d9f8ae9e16fe4aa5498( c64e934d9334b4d9f8ae9e16fe4aa5498 )



########################################
# [DSP: Normalize to 100%]
########################################
Normalize()

########################################
# [Encoder: OggVorbis (Q=3)]
########################################
6==Audiochannels(last)?GetChannel(last,1,3,2,5,6,4):last

Dark-Cracker
23rd December 2005, 11:43
is there a way to upmix 2ch audio file at 6ch using avisynth ?

dimzon
23rd December 2005, 11:45
is there a way to upmix 2ch audio file at 6ch using avisynth ?
I found some method but it requres REVERB function in AviSynth. I'm planning to write apropriate AviSynth plugin later.
http://forum.doom9.org/showthread.php?p=747809#post747809

dimzon
23rd December 2005, 12:02
Yet another petition: http://forum.doom9.org/showthread.php?p=756054#post756054

dimzon
23rd December 2005, 15:35
Yet another demo build (last per this year)
http://www.mytempdir.com/338780
Encoding not working yet!
+New Upmix exrtension (not working Yet!)
+Per-plugin settings persistance
+Normalize now have a GUI

Please post Your feedback/suggestions

Bye!

dimzon
26th December 2005, 15:00
http://img452.imageshack.us/img452/3268/bl04pg.gif
http://img484.imageshack.us/img484/7261/bl19mo.gif
http://www.mytempdir.com/343621

+ Preview
+ Encoding

Rockaria
3rd February 2006, 19:16
Wow, it's been a very long time!
I really appreciate everybody engaged in these projects, although I cannot contribute any more because too good many people are joined, almost certainly..(in fact I am busy). However, I had some different beliefs than what is going on.:)
# Call function
f64e934d9334b4d9f8ae9e16fe4aa5498( c64e934d9334b4d9f8ae9e16fe4aa5498 ) I understand it is emphasizing(almost upto frustration level) the equal unique names on both references : functions & varibles
But simply, any duplicated function names will be filtered by compiler or interpreter, while duplicate variables are not covered at all in this avisynth script.

I admire tebasuna51 for his generous personality, dimzon for his excellent inspirations and sorry for MiCK76's possible frustration.
Although it seemingly has some other issues(not that straightforward dsp, function, encoder definition and no profile management yet), I believe it will definitely benefit everybody.

Good luck guys.:)

Rockaria
19th February 2006, 12:27
Below is a (enhanced) guide(examples) for those who are using the Avisynth scripts for audio transcoding because of the compatibility requirements of the existing resources(especially for avs2wav). I also found that bepipe(cli)/behappy(gui) can utilize the existing compatible resources using import() method.

Now some side story of the 70/30 or 80/20 rule.
. the script based tools are more focused on power user requirements : 20~30% of users are considered using this flexible tool together with other powerful tools such as Sox?...
. 70~80% of the users who do not require sophiscated handling, will be satisfied by the existing abundant of GUI tools(winamp, dbpoweramp, foobar2k, Be~tools......) providing patternized processing
. my efforts are for some few of the power users who want the flexibility and transparency with Avisynth scripts, in other words the freedom and power...., which is also the basic/essential requirement of any new coming powerful simple tools(with just few hrs or days work).

<startEnc.cmd> for anybody who want multi tasking when performing a long transcoding

rem START ["title"] [/Dpath] [/i] [/MIN] [/MAX] [/SEPARATE | /SHARED]
rem [/LOW | /NORMAL | /HIGH | /REALTIME | /ABOVENORMAL | /BELOWNORMAL]
rem [/WAIT] [/b] [command/program]
start "encoding" /LOW profiles.cmd


<profiles.cmd> encoding profiles, yeah the bepipe can replace the avs2wav.

rem ---unlock the temporary FIX lines for avs2wav on the BOTTOM of the script
avs2wav.exe upmxdpl2.avs - | oggenc2.exe -q5 - -o 2.ogg
rem avs2wav.exe ogg6ch.avs - | oggenc2.exe -q5 - -o 6.ogg
rem avs2wav.exe aac2ch.avs | naac -profile he -vbr 5 - 2.m4a
rem avs2wav.exe aac6ch.avs | naac -profile he -vbr 5 - 6.m4a
rem avs2wav.exe aac6chB.avs | naac -profile lc -vbr 8 - 8B.m4a

rem ---somebody might be able to fix the flexibility problem of behappy using IMPORT()
rem bepipe.exe --script "import(^upmxdpl2.avs^)" | oggenc2.exe -q5 - -o 2.ogg
rem bepipe.exe --script "import(^aac6ch.avs^)" | naac -profile he -vbr 5 - 6.m4a

rem avs2wav.exe upmxdpl2.avs


<upmxdpl2.avs> : (2ch->upmix) / 6ch->(dpl2), check the avs2wav temporary fix on the bottom, preview(play) the script with MPC(or any DS media players) before encoding.

import("upmix.avs")
import("dpl2enc.avs")

DirectShowSource("1.mp3")
#NicDTSSource("1.dts")
#DirectShowSource("1.m4a")
#DirectShowSource("SSWAV06.m4a")
#DirectShowSource("DPLII.grf")

Amplify(0.92)
#AmplifydB(-1.01)

convertaudiotofloat()

#upmixComedyDrama(last)
#upmixActionAdventure(last)

upmixBalCenter(last)
#upmixIncCenter(last)
#upmixDecCenter(last)

#upmixGerzen(last)
#upmixFarina(last)
#upmixMultisonic(last)
#upmixSoundOnSound(last)


#dpl2FFDA(last)
#dpl2FFDLFEA(last)
#dpl2FFDA(last, 0.7)
dpl2Enc(last, 0.7071, 0.6, 0.866, -0.5, -0.5, 0.866)
#dpl2Enc(last, 0.707, 0.4, 0.8165, -0.5774, -0.5774, 0.8165)
#dpl2Enc(last, 0.7071, 0.4, 0.866, -0.5, -0.5, 0.866)
#dpl2Enc(last, 0.707, 0.4, 0.8165, -0.5774, -0.5774, 0.8165)

#ConvertAudioTo16Bit()
ConvertAudioTo24Bit()

SSRC(48000)
#Normalize()

#below are temporary fix for avs2wav : use SSRC if the 44.1k streaming is pending
#SSRC(48000).SSRC(44100)
#AudioDubEx(Trim(Colorbars(320,240),0,1),last)



<upmix.avs> a (heavy) reconstruction( for a compatibility) of NorthPole's (http://forum.doom9.org/showpost.php?p=787656&postcount=95) hardwork.

...

function invertFilter(clip a, fv, rv){return invertFilter(a,fv,-1*fv,rv)}
function invertFilter(clip a, fv1, fv2, rv){return invertFilter(a,fv1,fv2,rv,-1*rv,"vol -0.5")}
function invertFilter(clip a, fv1, fv2, rv1, rv2, lv){
f = a.soxfilter("filter 20-20000")
fl = f.GetChannel(1)
fr = f.GetChannel(2)

r = a.soxfilter("filter 100-7000").DelayAudio(0.02)
rl = r.GetChannel(1)
rr = r.GetChannel(2)

lfe = ConvertToMono(a).SoxFilter("lowpass 120", lv)

return MergeChannels(mixaudio(fl,fr,fv1,fv2),mixaudio(fr,fl,fv1,fv2), fl,fr, mixaudio(rl,rr,rv1,rv2),mixaudio(rr,rl,rv1,rv2), lfe)
}
function upmixComedyDrama(clip a){
# Profile to use with audio sources that have mostly mono content.
f = invertFilter(a, 0.794, 0.562)
l = f.GetChannel(1)
r = f.GetChannel(2)
c = mixaudio(mixaudio(f.GetChannel(3),l,1,-1),mixaudio(f.GetChannel(4),r,1,-1),0.224,0.224)

return MergeChannels(l,r,c,f.getChannel(7),f.getChannel(5),f.getChannel(6))
}
function upmixActionAdventure(clip a){
# Profile to use with audio sources that have a wider range of sound content. 20ms delay and -3db attenuation on surround
f = invertFilter(a, 0.668,-0.668, 0.473,-0.473, "vol -0.447")
l = f.GetChannel(1)
r = f.GetChannel(2)
c = mixaudio(mixaudio(f.GetChannel(3),l,1,-1),mixaudio(f.GetChannel(4),r,1,-1),0.398,0.398)
return MergeChannels(l, r, c, f.getChannel(7), f.getChannel(5), f.getChannel(6))
}
function upmixBalCenter(clip a){
# Balanced approach L' = (L-R)*0.668 R' = (R-L)*0.668 C' = (L-L')*0.398 + (R-R')*0.398
# Profile for general purposes to use with audio sources that have a wide range of sound content
f = invertFilter(a, 0.668, 0.531)
c = mixaudio(f.GetChannel(3),f.GetChannel(4),0.3980,0.3980)

return MergeChannels(f.getChannel(1), f.getChannel(2), c, f.getChannel(7), f.getChannel(5), f.getChannel(6))
}
function upmixDecCenter(clip a){
# Balanced approach L' = (L-R)*0.668 R' = (R-L)*0.668 C' = (L-L')*0.398 + (R-R')*0.398
# Profile to use for older movies or videos with mostly mono content.
f = invertFilter(a, 0.668,-0.668, 0.531,-0.531, "vol -0.596")
l = f.GetChannel(1)
r = f.GetChannel(2)
c = mixaudio(mixaudio(f.GetChannel(3),l,1,-1),mixaudio(f.GetChannel(4),r,1,-1),0.224,0.224)

return MergeChannels(l,r,c,f.getChannel(7),f.getChannel(5),f.getChannel(6))
}
function upmixIncCenter(clip a){
# Increased center approach L' = (L-R)*0.596 R' = (R-L)*0.596 C' = (L-L')*0.473 + (R-R')*0.473
# Profile to use with audio sources where quieter dialog or lots of loud sound effects.
f = invertFilter(a, 0.596,-0.596, 0.473,-0.473, "vol -0.473")
l = f.GetChannel(1)
r = f.GetChannel(2)
c = mixaudio(mixaudio(f.GetChannel(3),l,1,-1),mixaudio(f.GetChannel(4),r,1,-1),0.473,0.473)

return MergeChannels(l,r,c,f.getChannel(7),f.getChannel(5),f.getChannel(6))
}
function upmixGerzen(clip a){
# Gerzen approach Profile modified with 20ms delay and some attenuation on surround
f = invertFilter(a, 0.885, -0.115, 0.668)
c = mixaudio(f.GetChannel(3),f.GetChannel(4),0.4511,0.4511)

return MergeChannels(f.getChannel(1),f.getChannel(2),c,f.getChannel(7),f.getChannel(5), f.getChannel(6))
}
function upmixMultisonic(clip a){
# Multisonic approach Profile modified with 20ms delay and some attenuation on surround
f = invertFilter(a, 0.9,-0.45, 0.596)
c = mixaudio(f.GetChannel(3),f.GetChannel(4),0.5000,0.5000)

return MergeChannels(f.getChannel(1),f.getChannel(2),c,f.getChannel(7),f.getChannel(5), f.getChannel(6))
}

function upmixFarina(clip a){
# Farina/Sursound approach Profile M=L+R, S=L-R, c=0.75, L' = (1-c/4)*M+(1+c/4)*S, C' = c*M, R' = (1-c/4)*M-(1+c/4)*S
f = invertFilter(a, 0.500, 0.668)
ff= mixaudio(f.getChannel(3),f.getChannel(4),0.500,0.500)
l= mixaudio(ff,f.getchannel(1),0.8125,1.1875)
r= mixaudio(ff,f.getchannel(2),0.8125,-1.1875)

c = mixaudio(f.GetChannel(3),f.GetChannel(4),0.3750,0.3750)

return MergeChannels(l, r, c, f.getChannel(7), f.getChannel(5), f.getChannel(6))
}

function upmixSoundOnSound(clip a){
# SOS approach Profile with 20ms delay and some attenuation on surround
f = invertFilter(a, 0.000, 0.668)
c = mixaudio(a.GetChannel(1),a.GetChannel(2),0.5,0.5)
return MergeChannels(f.getChannel(3), f.getChannel(4), c, f.getChannel(7), f.getChannel(5), f.getChannel(6))
}


<dpl2enc.avs> for those who have experienced the existing DPL II encoders(FFDShow, Azid, ...) are not decoding correctly on digital receivers or headphones(2ch).

...
function dpl2FFD(clip a){return dpl2FFD(a, 0)}
function dpl2FFDLFE(clip a){return dpl2FFD(a, 0.7)}
function dpl2FFD(clip a, LF2){return dpl2Enc(a, 0.7071, LF2, -0.866, -0.5, 0.5, 0.866)}
function dpl2FFDA(clip a){return dpl2FFDA(a, 0)}
function dpl2FFDA(clip a, LF2){return dpl2Enc(a, 0.7071, LF2, 0.866, -0.5, -0.5, 0.866)}
function dpl2FFDLFEA(clip a){return dpl2FFDA(a, 0.7)}
function dpl2Enc(clip a, CC2, LF2, Ls3, Rs1, Ls1, Rs3){
cc = MixAudio(GetChannel(a, 3),GetChannel(a, 4),CC2,LF2)
Lt = MixAudio(GetChannel(a, 1),cc,1,1)
Rt = MixAudio(GetChannel(a, 2),cc,1,1)

Ls = GetChannel(a, 5)
Rs = GetChannel(a, 6)
Lss = MixAudio(Ls, RS, LS3, Rs1)
Rss = MixAudio(Ls, RS, LS1, Rs3)
return MergeChannels(MixAudio(Lt,Lss,1,1), MixAudio(Rt,Rss,1,1))
}


Closure.

sjchmura
6th March 2006, 22:29
I am a bit confused ....

If we have a DTS 5.1 ripped (U2 live chicago say :) and want 2 channel with HFRT "3D" encoded INTO it so on say an iPOD it "sounds like" 5.1 can you not use FFDShow and AVIsynth to achieve this? I ant to "build in" the effect to the 2 Channel sound so ANY player gives the "effect"