|
09-01-2017, 02:33 AM
|
#1
|
Human being with feelings
Join Date: Aug 2017
Posts: 50
|
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
|
|
|
09-01-2017, 04:45 AM
|
#2
|
Human being with feelings
Join Date: May 2012
Location: PA, USA
Posts: 356
|
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.
|
|
|
09-01-2017, 05:17 AM
|
#3
|
Human being with feelings
Join Date: Feb 2007
Location: Oulu, Finland
Posts: 8,062
|
Quote:
Originally Posted by random_id
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.)
__________________
I am no longer part of the REAPER community. Please don't contact me with any REAPER-related issues.
|
|
|
09-01-2017, 05:22 AM
|
#4
|
Human being with feelings
Join Date: Aug 2017
Posts: 50
|
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
|
|
|
09-01-2017, 05:26 AM
|
#5
|
Human being with feelings
Join Date: May 2012
Location: PA, USA
Posts: 356
|
Quote:
Originally Posted by Xenakios
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?
|
|
|
09-01-2017, 05:28 AM
|
#6
|
Human being with feelings
Join Date: Feb 2007
Location: Oulu, Finland
Posts: 8,062
|
Quote:
Originally Posted by JonOsterman
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?
__________________
I am no longer part of the REAPER community. Please don't contact me with any REAPER-related issues.
|
|
|
09-01-2017, 05:30 AM
|
#7
|
Human being with feelings
Join Date: Feb 2007
Location: Oulu, Finland
Posts: 8,062
|
Quote:
Originally Posted by random_id
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.
__________________
I am no longer part of the REAPER community. Please don't contact me with any REAPER-related issues.
|
|
|
09-01-2017, 05:35 AM
|
#8
|
Human being with feelings
Join Date: Aug 2017
Posts: 50
|
Quote:
Originally Posted by Xenakios
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
|
|
|
09-01-2017, 05:38 AM
|
#9
|
Human being with feelings
Join Date: Feb 2007
Location: Oulu, Finland
Posts: 8,062
|
Quote:
Originally Posted by JonOsterman
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?
__________________
I am no longer part of the REAPER community. Please don't contact me with any REAPER-related issues.
|
|
|
09-01-2017, 05:46 AM
|
#10
|
Human being with feelings
Join Date: Aug 2017
Posts: 50
|
Quote:
Originally Posted by Xenakios
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
|
|
|
09-06-2017, 06:23 AM
|
#11
|
Human being with feelings
Join Date: Aug 2017
Posts: 50
|
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.
|
|
|
09-06-2017, 07:49 AM
|
#12
|
Human being with feelings
Join Date: Feb 2007
Location: Oulu, Finland
Posts: 8,062
|
Quote:
Originally Posted by JonOsterman
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.
__________________
I am no longer part of the REAPER community. Please don't contact me with any REAPER-related issues.
Last edited by Xenakios; 09-06-2017 at 08:03 AM.
|
|
|
09-06-2017, 08:14 AM
|
#13
|
Human being with feelings
Join Date: Aug 2017
Posts: 50
|
Quote:
Originally Posted by Xenakios
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 ?
|
|
|
09-06-2017, 08:20 AM
|
#14
|
Human being with feelings
Join Date: Feb 2007
Location: Oulu, Finland
Posts: 8,062
|
Quote:
Originally Posted by JonOsterman
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...
__________________
I am no longer part of the REAPER community. Please don't contact me with any REAPER-related issues.
Last edited by Xenakios; 09-06-2017 at 08:26 AM.
|
|
|
09-06-2017, 08:38 AM
|
#15
|
Human being with feelings
Join Date: Aug 2017
Posts: 50
|
Quote:
Originally Posted by Xenakios
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.
|
|
|
09-06-2017, 08:42 AM
|
#16
|
Human being with feelings
Join Date: Feb 2007
Location: Oulu, Finland
Posts: 8,062
|
Quote:
Originally Posted by JonOsterman
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.
__________________
I am no longer part of the REAPER community. Please don't contact me with any REAPER-related issues.
|
|
|
09-06-2017, 08:56 AM
|
#17
|
Human being with feelings
Join Date: Aug 2017
Posts: 50
|
Quote:
Originally Posted by Xenakios
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
|
|
|
09-06-2017, 11:24 PM
|
#18
|
Human being with feelings
Join Date: Jul 2008
Location: The Netherlands
Posts: 3,645
|
Quote:
Originally Posted by Xenakios
WDL and IPlug unfortunately do not have the facilities to read audio files, though.
|
Well, my WDL contains a simple WAVE file reader.
|
|
|
09-07-2017, 01:06 AM
|
#19
|
Human being with feelings
Join Date: Aug 2017
Posts: 50
|
Quote:
Originally Posted by Tale
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() ?
|
|
|
09-07-2017, 01:47 AM
|
#20
|
Human being with feelings
Join Date: Jul 2008
Location: The Netherlands
Posts: 3,645
|
Quote:
Originally Posted by JonOsterman
I'm curious, I assume that it is wavread.h ?
|
Yes.
Quote:
Originally Posted by JonOsterman
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
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.
|
|
|
09-08-2017, 05:37 AM
|
#21
|
Human being with feelings
Join Date: Aug 2017
Posts: 50
|
Ok thanks
|
|
|
Thread Tools |
|
Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -7. The time now is 07:30 AM.
|