INTERACT FORUM

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1]   Go Down

Author Topic: Expression Language - Math function on Sample Rate  (Read 1599 times)

haylo75

  • Regular Member
  • Junior Woodchuck
  • **
  • Posts: 61
Expression Language - Math function on Sample Rate
« on: November 21, 2012, 07:47:42 pm »

I'm trying to display Sample Rate in an Expression Column as kHz rather than Hz.  I tried Math([Sample Rate] / 1000) with the intent of wrapping a formatting function around it.  Apparently [Sample Rate] is evaluated as a string as any Math whatsoever returns 0.  Am I missing something simple?  If not, can MC be modified so that Math may be applied to [Sample Rate]?

Thanks!
Logged
Kerr

haylo75

  • Regular Member
  • Junior Woodchuck
  • **
  • Posts: 61
Re: Expression Language - Math function on Sample Rate
« Reply #1 on: November 21, 2012, 08:25:22 pm »

I see now why I cannot perform Math on [Sample Rate] as it's formatted like so, "44100 Hz".  Stripping non-numerics did the trick.  I have a solution sorted out.  It's not the prettiest, but it got me what I needed.  The expression:

Code: [Select]
If(IsEmpty([Bit Depth]),?,[Bit Depth])//FormatNumber(Math(Regex([Sample Rate],/#([0-9]+)#/,1)/1000),1)
The output:
16/44.1
24/96
24/88.2
24/176.4

... or Bit Depth/Sample Rate, in kHz, 1 decimal place precision when required.

Expression Language FTW once again!
Logged
Kerr

MrC

  • Citizen of the Universe
  • *****
  • Posts: 10462
  • Your life is short. Give me your money.
Re: Expression Language - Math function on Sample Rate
« Reply #2 on: November 21, 2012, 08:52:37 pm »

Use [Sample Rate,0] and [Bit Depth,0].  The ,0 means to output raw, rather than formatted.
Logged
The opinions I express represent my own folly.

haylo75

  • Regular Member
  • Junior Woodchuck
  • **
  • Posts: 61
Re: Expression Language - Math function on Sample Rate
« Reply #3 on: November 22, 2012, 09:00:45 am »

MrC, thank you, that's good to know!  I may have missed that in the wiki entry.  That simplified my Expression:

Code: [Select]
If(IsEmpty([Bit Depth]),?,[Bit Depth])//FormatNumber(Math([Sample Rate,0]/1000),1)
Logged
Kerr

ferday

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1732
Re: Expression Language - Math function on Sample Rate
« Reply #4 on: November 24, 2012, 11:45:34 am »

Thanks for this, I was looking to do the same thing but hadn't got as far as trying yet
Logged
Pages: [1]   Go Up