COCKOS
CONFEDERATED FORUMS
Cockos : REAPER : NINJAM : Forums
Forum Home : Register : FAQ : Members List : Search :
Old 09-01-2017, 02:33 AM   #1
JonOsterman
Human being with feelings
 
Join Date: Aug 2017
Posts: 47
Default Get file info

Hi,

I was wondering if there is a way to get infos from the file or the stream ? like file format, sampling rate, number of channels, etc. ?

Thank you in advance
JonOsterman is offline   Reply With Quote
Old 09-01-2017, 04:45 AM   #2
random_id
Human being with feelings
 
random_id's Avatar
 
Join Date: May 2012
Location: PA, USA
Posts: 311
Default

Are you talking about opening a file outside of the plugin, or are you talking about getting the information from the DAW about the data that is being processed by the plugin?

The second one is easy, and there are many methods within IPlug for getting samplerate, channels, etc. Look in IPlugBase.h for things like GetSampleRate(), GetLatency(), etc.

As for the first question, I think that would be a little harder.
__________________
Website: LVC-Audio
random_id is offline   Reply With Quote
Old 09-01-2017, 05:17 AM   #3
Xenakios
Human being with feelings
 
Xenakios's Avatar
 
Join Date: Feb 2007
Location: Oulu, Finland
Posts: 6,722
Default

Quote:
Originally Posted by random_id View Post
there are many methods within IPlug for getting samplerate, channels
Those however are not guaranteed to have anything to do with the audio files on the host's tracks. (Especially in a host like Reaper which can automatically sample rate convert and allow changing which channels of an audio file are playing etc.)
__________________
For info on SWS Reaper extension plugin (including Xenakios' previous extension/actions) :
http://www.sws-extension.org/
https://github.com/Jeff0S/sws
--
Xenakios blog (about HourGlass and λ) :
http://xenakios.wordpress.com/
Xenakios is online now   Reply With Quote
Old 09-01-2017, 05:22 AM   #4
JonOsterman
Human being with feelings
 
Join Date: Aug 2017
Posts: 47
Default

I'm talking about the second one, because I want to be sure that I work on the good type of file.

I will take a look at IPlugBase.h and come back if I got any problems or question, thanks
JonOsterman is offline   Reply With Quote
Old 09-01-2017, 05:26 AM   #5
random_id
Human being with feelings
 
random_id's Avatar
 
Join Date: May 2012
Location: PA, USA
Posts: 311
Default

Quote:
Originally Posted by Xenakios View Post
Those however are not guaranteed to have anything to do with the audio files on the host's tracks. (Especially in a host like Reaper which can automatically sample rate convert and allow changing which channels of an audio file are playing etc.)
Now you are toying with my sanity. I guess those methods only show what is coming into the plugin, not what has happened prior to that point?
__________________
Website: LVC-Audio
random_id is offline   Reply With Quote
Old 09-01-2017, 05:28 AM   #6
Xenakios
Human being with feelings
 
Xenakios's Avatar
 
Join Date: Feb 2007
Location: Oulu, Finland
Posts: 6,722
Default

Quote:
Originally Posted by JonOsterman View Post
I'm talking about the second one, because I want to be sure that I work on the good type of file.
Things don't work like that with plugins. You can not know about the format of the file that is playing in the host. Why would you need to know about that anyway?
__________________
For info on SWS Reaper extension plugin (including Xenakios' previous extension/actions) :
http://www.sws-extension.org/
https://github.com/Jeff0S/sws
--
Xenakios blog (about HourGlass and λ) :
http://xenakios.wordpress.com/
Xenakios is online now   Reply With Quote
Old 09-01-2017, 05:30 AM   #7
Xenakios
Human being with feelings
 
Xenakios's Avatar
 
Join Date: Feb 2007
Location: Oulu, Finland
Posts: 6,722
Default

Quote:
Originally Posted by random_id View Post
I guess those methods only show what is coming into the plugin, not what has happened prior to that point?
That's right, they show the properties of the audio the host determines and might not have anything to do with the original audio files themselves.
__________________
For info on SWS Reaper extension plugin (including Xenakios' previous extension/actions) :
http://www.sws-extension.org/
https://github.com/Jeff0S/sws
--
Xenakios blog (about HourGlass and λ) :
http://xenakios.wordpress.com/
Xenakios is online now   Reply With Quote
Old 09-01-2017, 05:35 AM   #8
JonOsterman
Human being with feelings
 
Join Date: Aug 2017
Posts: 47
Default

Quote:
Originally Posted by Xenakios View Post
Things don't work like that with plugins. You can not know about the format of the file that is playing in the host. Why would you need to know about that anyway?
Because for now I only can process 48KHz, .wav and I don't handle 8bits
JonOsterman is offline   Reply With Quote
Old 09-01-2017, 05:38 AM   #9
Xenakios
Human being with feelings
 
Xenakios's Avatar
 
Join Date: Feb 2007
Location: Oulu, Finland
Posts: 6,722
Default

Quote:
Originally Posted by JonOsterman View Post
Because for now I only can process 48KHz, .wav and I don't handle 8bits
Doesn't sound like your processing is really suitable for a plugin then...Or have we misunderstood and you are not working to do a VST/AU plugin?
__________________
For info on SWS Reaper extension plugin (including Xenakios' previous extension/actions) :
http://www.sws-extension.org/
https://github.com/Jeff0S/sws
--
Xenakios blog (about HourGlass and λ) :
http://xenakios.wordpress.com/
Xenakios is online now   Reply With Quote
Old 09-01-2017, 05:46 AM   #10
JonOsterman
Human being with feelings
 
Join Date: Aug 2017
Posts: 47
Default

Quote:
Originally Posted by Xenakios View Post
Doesn't sound like your processing is really suitable for a plugin then...Or have we misunderstood and you are not working to do a VST/AU plugin?
My first version was a Command Line program which has nothing to see with a VST/AU, but I made an adaptation to VST, so this way people can use it in addition to their live performance. It worked but because I know that for now I can't handle some specific kind of files I want to frame the user experience, if I can say so
JonOsterman is offline   Reply With Quote
Old 09-06-2017, 06:23 AM   #11
JonOsterman
Human being with feelings
 
Join Date: Aug 2017
Posts: 47
Default

Hi,

IPlugBase.h contained a lot of useful methods, but I can't find anything about the bits per sample (8, 16, 32, ... bits). Do you guys know something about it ?

I've seen GetSamplePerBeats() and GetBlockSize(), but that's not doing what I need


EDIT : I've found this :

Bit rate = bit per sample x (sampling rate) x (number of channels), so :
Bits per sample = (Bit Rate / Nb Channels) * Sampling Rate ^ -1

Do you know if it's easier to get Bit Rate ?

Thanks

Last edited by JonOsterman; 09-06-2017 at 07:45 AM.
JonOsterman is offline   Reply With Quote
Old 09-06-2017, 07:49 AM   #12
Xenakios
Human being with feelings
 
Xenakios's Avatar
 
Join Date: Feb 2007
Location: Oulu, Finland
Posts: 6,722
Default

Quote:
Originally Posted by JonOsterman View Post
IPlugBase.h contained a lot of useful methods, but I can't find anything about the bits per sample (8, 16, 32, ... bits)
I can only repeat what I've written earlier : your plugin can NOT know the bit depth (or sample rate or number of channels) of the audio files in the DAW application. Plugins only process 32 or 64 bit floating point audio buffers.

In IPlug, you have to implement your audio processing in an implementation of this function :

virtual void ProcessDoubleReplacing(double** inputs, double** outputs, int nFrames);

As you can see, you only get 64 bit floating point buffers and need to write the audio into 64 bit floating point buffers. You have no way of knowing where the audio is coming from or where it will be going.
__________________
For info on SWS Reaper extension plugin (including Xenakios' previous extension/actions) :
http://www.sws-extension.org/
https://github.com/Jeff0S/sws
--
Xenakios blog (about HourGlass and λ) :
http://xenakios.wordpress.com/

Last edited by Xenakios; 09-06-2017 at 08:03 AM.
Xenakios is online now   Reply With Quote
Old 09-06-2017, 08:14 AM   #13
JonOsterman
Human being with feelings
 
Join Date: Aug 2017
Posts: 47
Default

Quote:
Originally Posted by Xenakios View Post
I can only repeat what I've written earlier : your plugin can NOT know the bit depth (or sample rate or number of channels) of the audio files in the DAW application. Plugins only process 32 or 64 bit floating point audio buffers.

In IPlug, you have to implement your audio processing in an implementation of this function :

virtual void ProcessDoubleReplacing(double** inputs, double** outputs, int nFrames);

As you can see, you only get 64 bit floating point buffers and need to write the audio into 64 bit floating point buffers. You have no way of knowing where the audio is coming from or where it will be going.
Ok, but what are the roles of GetSampleRate() or NInChannels() methods then ?
JonOsterman is offline   Reply With Quote
Old 09-06-2017, 08:20 AM   #14
Xenakios
Human being with feelings
 
Xenakios's Avatar
 
Join Date: Feb 2007
Location: Oulu, Finland
Posts: 6,722
Default

Quote:
Originally Posted by JonOsterman View Post
Ok, but what are the roles of GetSampleRate() or NInChannels() methods then ?
They tell the current sample rate and number of channels in the DAW's audio processing chain. They may sometimes be the same as the sample rate and number of channels of an audio file that may be in the DAW's track, but generally you can not assume they are the same thing. Remember that there might not be an audio file involved in the DAW application itself at all, the audio might, for example, be coming from a synthesizer plugin that is inserted before your plugin...
__________________
For info on SWS Reaper extension plugin (including Xenakios' previous extension/actions) :
http://www.sws-extension.org/
https://github.com/Jeff0S/sws
--
Xenakios blog (about HourGlass and λ) :
http://xenakios.wordpress.com/

Last edited by Xenakios; 09-06-2017 at 08:26 AM.
Xenakios is online now   Reply With Quote
Old 09-06-2017, 08:38 AM   #15
JonOsterman
Human being with feelings
 
Join Date: Aug 2017
Posts: 47
Default

Quote:
Originally Posted by Xenakios View Post
in the DAW application, the audio might, for example, be coming from a synthesizer plugin that is inserted before your plugin...
So IPlug can't help me here, but I have just a thought : RIFF format (for wav for example) contains the data I need, but if I understand you I have no way to know what audio is playing, because DAWs mux it and create its own audio stream or because plugins can't access those datas ?

Last edited by JonOsterman; 09-06-2017 at 08:51 AM.
JonOsterman is offline   Reply With Quote
Old 09-06-2017, 08:42 AM   #16
Xenakios
Human being with feelings
 
Xenakios's Avatar
 
Join Date: Feb 2007
Location: Oulu, Finland
Posts: 6,722
Default

Quote:
Originally Posted by JonOsterman View Post
if I understand you I have no way to know what audio is playing, because DAWs mux it and create its own audio stream or because plugins can't access those datas ?
That is right.

If you really need to be able to read, process and play back an audio file in a particular format, you can obviously implement that in your plugin. After all, that is what for example sampler instrument plugins do...WDL and IPlug unfortunately do not have the facilities to read audio files, though.
__________________
For info on SWS Reaper extension plugin (including Xenakios' previous extension/actions) :
http://www.sws-extension.org/
https://github.com/Jeff0S/sws
--
Xenakios blog (about HourGlass and λ) :
http://xenakios.wordpress.com/
Xenakios is online now   Reply With Quote
Old 09-06-2017, 08:56 AM   #17
JonOsterman
Human being with feelings
 
Join Date: Aug 2017
Posts: 47
Default

Quote:
Originally Posted by Xenakios View Post
If you really need to be able to read, process and play back an audio file in a particular format, you can obviously implement that in your plugin.
I'll give it a try, thanks
JonOsterman is offline   Reply With Quote
Old 09-06-2017, 11:24 PM   #18
Tale
Human being with feelings
 
Tale's Avatar
 
Join Date: Jul 2008
Location: Holland
Posts: 2,834
Default

Quote:
Originally Posted by Xenakios View Post
WDL and IPlug unfortunately do not have the facilities to read audio files, though.
Well, my WDL contains a simple WAVE file reader.
Tale is offline   Reply With Quote
Old 09-07-2017, 01:06 AM   #19
JonOsterman
Human being with feelings
 
Join Date: Aug 2017
Posts: 47
Default

Quote:
Originally Posted by Tale View Post
Well, my WDL contains a simple WAVE file reader.

I'm curious, I assume that it is wavread.h ? how does it work ?

what does return GetLength() and GetSize() ?
JonOsterman is offline   Reply With Quote
Old 09-07-2017, 01:47 AM   #20
Tale
Human being with feelings
 
Tale's Avatar
 
Join Date: Jul 2008
Location: Holland
Posts: 2,834
Default

Quote:
Originally Posted by JonOsterman View Post
I'm curious, I assume that it is wavread.h ?
Yes.

Quote:
Originally Posted by JonOsterman View Post
how does it work ?
Code:
#include <stdio.h>
#include "WDL/wavread.h"

int main()
{
	WaveReader wav;
	if (!wav.Open("meh.wav"))
	{
		printf("Oops!\n");
		return 1;
	}

	static const int maxLen = 1024;
	int n = wav.GetLength();
	if (n > maxLen) n = maxLen;

	double buf[maxLen], *ptr = buf;
	static const int ofs = 0, nch = 1;
	n = wav.ReadDoublesNI(&ptr, ofs, n, nch);

	for (int i = 0; i < n; ++i)
	{
		printf("[%d] %g\n", i, buf[i]);
	}

	return 0;
}
Quote:
Originally Posted by JonOsterman View Post
what does return GetLength() and GetSize() ?
GetLength() returns the length of the WAVE file in samples. GetSize() returns the total number of samples in the WAVE file i.e. GetLength()*get_nch(), where get_nch() returns the number of channels.
Tale is offline   Reply With Quote
Old 09-08-2017, 05:37 AM   #21
JonOsterman
Human being with feelings
 
Join Date: Aug 2017
Posts: 47
Default

Ok thanks
JonOsterman is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 02:18 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2017, vBulletin Solutions Inc.