Author Topic: coding...  (Read 19707 times)

haze

  • Newbie
  • *
  • Posts: 29
    • View Profile
coding...
« on: March 23, 2009, 17:50:45 »
hi,

can you please look at my codes in the process call, am i doing the right coding.

VocalRangeAnalyzerPlugin::FeatureSet
VocalRangeAnalyzerPlugin::process(const float *const *inputBuffers,
                                 Vamp::RealTime timestamp)
{
    FeatureSet returnFeatures;

    if (m_stepSize == 0) {
        std::cerr << "VocalRangeAnalyzerPlugin::process:  Plugin not initialised" << std::endl;
        return returnFeatures;
    }

    for (size_t i = 0; i < m_stepSize; ++i) {
        for (size_t j = 0; j < m_channelCount; ++j) {
            fvec_write_sample(m_ibuf, inputBuffers[j], j, i);
        }
    }

      calculate();

      if (minFreq >= 80 && maxFreq <= 310){
         feature.label = "bass";}

      else if(minFreq >= 100 && maxFreq <= 440){
         feature.label ="baritone";}
         
      else if(minFreq >=130 && maxFreq <= 500){
         feature.label = "tenor";}

      else if(minFreq >= 160 && maxFreq <= 650){
         feature.label = "alto";}

      else if(minFreq >= 210 && maxFreq <= 900){
         feature.label = "mezzo-soprano";}

      else if(minFreq >= 270 && maxFreq <= 1100){
         feature.label = "soprano";}

   
   Feature feature;
    feature.hasTimestamp = true;
    feature.timestamp = m_currentOnset +
            RealTime::frame2RealTime(i * m_stepSize, m_inputSampleRate);
   feature.hasDuration = true;
    feature.duration = offTime - m_currentOnset;
    feature.values.push_back(freq);

    returnFeatures[0].push_back(feature);
    return returnFeatures;
}

void
VocalRangeAnalyzerPlugin::calculate()
{
   float freq = aubio_pitchdetection(m_pitchdet, m_ibuf);
   

   for(int i=0; i<m_stepSize; i++)
   {
      if(freq < minFreq){
         minFreq = freq;
      }
      else
         if(freq > maxFreq){
            maxFreq = freq;
         }

   isFirstTime(false);
   }
}
//consider all has been initialized

do i miss something, there's no error, i got a dll file but then it is not running in sonic v.

please help. thanks.

hazel

haze

  • Newbie
  • *
  • Posts: 29
    • View Profile
Re: coding...
« Reply #1 on: March 23, 2009, 19:12:48 »
Also, how do I remove the example plugins of vamp. I want only my plugin to be built. I tried deleting the examples.cpp files but everytime I build it, there's an error of cannot find files.

Thanks

Hazel

cannam

  • Administrator
  • Sr. Member
  • *****
  • Posts: 273
    • View Profile
Re: coding...
« Reply #2 on: March 24, 2009, 18:08:29 »
When you say it isn't running in SV, what do you mean? It doesn't appear in the menus, it appears in the menus but no data is generated and displayed, or it fails in some other way (e.g. crashes)?

You might find it simpler to test in vamp-simple-host, which prints out its results directly to the command prompt -- at least that way you would see immediately whether there are any results or not, whereas in SV you could theoretically have results that simply aren't visible because their timestamps are wrong, or some such.

I can't really comment on the usage of aubio, but I would wonder what m_currentOnset is as it doesn't appear to be set anywhere.

To remove the example plugins, it should only be necessary to remove the references to them from plugins.cpp (or whatever file your library main entry point is defined in -- it's plugins.cpp in the example set).  There are three references to each plugin (the #include for its header, the static adapter declaration, and the return value from vampGetPluginDescriptor), and you would need to remove them all.  Ensure that your vampGetPluginDescriptor function returns your own plugin's adapter when it is called with index value of 0, and returns 0 for any other index value.


Chris

haze

  • Newbie
  • *
  • Posts: 29
    • View Profile
Re: coding...
« Reply #3 on: June 20, 2009, 07:50:45 »
Hi.

I'm back. Regarding what I said that the .dll file is not running in SV, whenever I tried to open SV, it crashes down. It does not continue to open.

Where is the problem here? In the codes?

Pls. help. Thanks.

Hazel

cannam

  • Administrator
  • Sr. Member
  • *****
  • Posts: 273
    • View Profile
Re: coding...
« Reply #4 on: June 25, 2009, 15:33:29 »

Does SV crash as soon as you start it up (when your DLL is installed), or does it crash when you try to run the plugin?

Either way, I'm afraid the most likely thing is a bug in the plugin code.

If it crashes when you start SV, then the crash might be in the plugin's constructor function or in the plugin lookup code (vampGetPluginDescriptor -- are you remembering to return NULL when called with an index greater than the number of plugins in the library?)

If it crashes when you run the plugin, then the most likely thing would be a bug in initialize() or process().

Perhaps you might try running it in a debugger?

Again, I'd also suggest using vamp-simple-host as an alternative test host.  You could even use vamp-simple-host in a debugger...


Chris

haze

  • Newbie
  • *
  • Posts: 29
    • View Profile
Re: coding...
« Reply #5 on: June 26, 2009, 14:32:59 »
Hi

SV crashes as soon as I start it up (with my dll installed).


const VampPluginDescriptor *vampGetPluginDescriptor(unsigned int version,
                                                    unsigned int index)
{
 if (version < 1) return 0;

return vocalRangeAnalyzerPlugin.getDescriptor();
    return 0;
}

--How do I use vamp-simple-host? And what debugger do you suggest?

Thanks

Hazel

cannam

  • Administrator
  • Sr. Member
  • *****
  • Posts: 273
    • View Profile
Re: coding...
« Reply #6 on: June 29, 2009, 22:01:26 »
It looks like you wanted something more like

const VampPluginDescriptor *vampGetPluginDescriptor(unsigned int version, unsigned int index)
{
  if (version < 1) return 0;
  if (index == 0) return vocalRangeAnalyzerPlugin.getDescriptor();
  else return 0;
}

Note that it only returns a plugin descriptor when called with index 0.

The principle of this function, generally speaking, is that it allows the plugin library to contain many different plugins, identified with different index values.  The host calls this function, repeatedly with index values incrementing from 0, and with each call it gets back a new plugin descriptor.  When it gets back a null descriptor (or 0 -- same thing), then it stops.

So, with a function as you quoted it, the host will keep calling this function forever, getting a new (identical) descriptor object each time -- because the function returns a new object regardless of the value of the index parameter.

Hope this helps!


Chris

haze

  • Newbie
  • *
  • Posts: 29
    • View Profile
Re: coding...
« Reply #7 on: July 01, 2009, 14:23:20 »
Hi.

I tried the codes you've given me, but still SV crashes as it starts.

What could possibly be the problem here?

Thanks.

cannam

  • Administrator
  • Sr. Member
  • *****
  • Posts: 273
    • View Profile
Re: coding...
« Reply #8 on: July 06, 2009, 12:46:41 »
Well, when SV starts up it does the following in order to build up its plugin menu:

 -- opens the plugin DLL
 -- calls vampGetPluginDescriptor repeatedly, with values starting at 0 and increasing by 1, until vampGetPluginDescriptor returns a NULL (or zero) value
 -- constructs each plugin whose descriptor was returned, calls getOutputDescriptors() on it, then destroys it again

This suggests various places where troubles could arise:

 -- the plugin's constructor?
 -- the getOutputDescriptors function?
 -- the destructor?

Note that initialise() and process() are not called on startup, so this crash shouldn't be in either of those.

It's also possible to run into problems if, for example, you compile the plugin using one version of the Vamp plugin SDK and link (perhaps dynamically) with a different version.  Make sure you're using version 2.0 of the SDK libraries and headers.

Can you try running SV in your IDE's debugger? -- for example in Visual Studio you can configure the Debug command to run a particular executable instead of the thing you were just compiling, so you could tell it to run the Sonic Visualiser executable (e.g. in VS2008 Project -> Properties -> Configuration Properties -> Debugging -> Executable).  Hopefully you should get a workable stack trace when it crashes.


Chris
« Last Edit: July 06, 2009, 12:54:15 by cannam »

haze

  • Newbie
  • *
  • Posts: 29
    • View Profile
Re: coding...
« Reply #9 on: July 07, 2009, 14:49:38 »
Hi.

I've tried to configure the Debug command as you say so but still I get the same result. It still crashes.

Do you mean I have to get the codes of Sonic V. to run in Visual Studio?

I am using ver.2.0 of the SDK libraries and headers.

Thanks a lot.

Hazel

cannam

  • Administrator
  • Sr. Member
  • *****
  • Posts: 273
    • View Profile
Re: coding...
« Reply #10 on: July 09, 2009, 16:01:39 »
If you run SV by configuring Visual Studio to run it as its debug command and then using the "Start Debugging" option in Visual Studio, it should run SV as normal, but when it crashes, it should show you a stack trace (in the debug frame which I think should be at bottom-right of the main window normally in Visual Studio).  Does it not do that?

It might not turn out to be meaningful, but it's possible that it might be.


Chris

haze

  • Newbie
  • *
  • Posts: 29
    • View Profile
Re: coding...
« Reply #11 on: July 11, 2009, 05:19:26 »
Hi

It says 'Unable to start Sonic Visualiser. The system cannot find the file specified'

Hazel

haze

  • Newbie
  • *
  • Posts: 29
    • View Profile
Re: coding...
« Reply #12 on: July 15, 2009, 13:55:47 »
Hi.

I got this error log, what does it mean?


Faulting application sonic visualiser.exe, version 0.0.0.0, faulting module vamp-example-plugins.dll, version 0.0.0.0, fault address 0x0009a966.

Hazel

cannam

  • Administrator
  • Sr. Member
  • *****
  • Posts: 273
    • View Profile
Re: coding...
« Reply #13 on: July 16, 2009, 15:40:12 »
Well, I think that just means it crashed!  Is there no stack trace offered?  It's usually available in the information pane at the bottom right of the Visual Studio debugger window.


Chris

haze

  • Newbie
  • *
  • Posts: 29
    • View Profile
Re: coding...
« Reply #14 on: August 15, 2009, 03:34:35 »
Hi

I tried to debug using Sonic Visualiser. Then prompts  "Unhandled exception at 0x0256a966 (vamp-example-plugins.dll) in Sonic Visualiser.exe: 0xC0000005: Access violation reading location 0xcdcdcdd1" and asked to break or continue. I Tried to continue and the stack traces are:

vamp-example-plugins.dll!del_fvec(_fvec_t * s=0xcdcdcdcd)  Line 42 + 0x18 bytes   C++

    vamp-example-plugins.dll!VocalRangeAnalyzerPlugin::~VocalRangeAnalyzerPlugin()  Line 77 + 0x15 bytes   C++

    vamp-example-plugins.dll!VocalRangeAnalyzerPlugin::`scalar deleting destructor'()  + 0x2b bytes   C++

    vamp-example-plugins.dll!_VampPlugin::Vamp::PluginAdapterBase::Impl::getDescriptor()  Line 264 + 0x34 bytes   C++

    vamp-example-plugins.dll!_VampPlugin::Vamp::PluginAdapterBase::getDescriptor()  Line 150   C++

    vamp-example-plugins.dll!vampGetPluginDescriptor(unsigned int version=2, unsigned int index=0)  Line 59 + 0x10 bytes   C++

    Sonic Visualiser.exe!006aa72b()    
    [Frames below may be incorrect and/or missing, no symbols loaded for Sonic Visualiser.exe]   
    Sonic Visualiser.exe!006ae919()    
    Sonic Visualiser.exe!00590090()    
    Sonic Visualiser.exe!00b490f0()    
    Sonic Visualiser.exe!0126fb22()    
    Sonic Visualiser.exe!00b490f0()    
    Sonic Visualiser.exe!0042d383()    
    msvcrt.dll!77c2c2de()    
    Sonic Visualiser.exe!0158c6be()    
    Sonic Visualiser.exe!0043ec7f()    
    Sonic Visualiser.exe!00423c9b()    
    Sonic Visualiser.exe!00423c9b()    
    Sonic Visualiser.exe!0042c6fd()    
    msvcrt.dll!77c50000()    
    msvcrt.dll!77c50000()    
    msvcrt.dll!77c39d60()    
    Sonic Visualiser.exe!004011c2()    
    Sonic Visualiser.exe!00401253()    
    ntdll.dll!7c90e64e()    
    kernel32.dll!7c816d4c()    
    kernel32.dll!7c816d4f()    
    kernel32.dll!7c8399f3()    
    Sonic Visualiser.exe!0069006c()

Thanks a lot.

Hazel