Author Topic: Translate C code to O2  (Read 222 times)

0 Members and 1 Guest are viewing this topic.

Alex_Longard

  • Newbie
  • *
  • Posts: 20
Translate C code to O2
« on: July 12, 2018, 04:12:21 AM »
Hello all!
Help me please!
I'am translate Steinberg VST2 sdk to O2 and have some problems, because I do not know well C.
How to write this code in O2:

Code: [Select]
typedef VstIntPtr (VSTCALLBACK *audioMasterCallback) (AEffect* effect, VstInt32 opcode, VstInt32 index, VstIntPtr value, void* ptr, float opt);


PS: vstint32 - int, vstintptr - pointer.

Thanks in advance!

Charles Pegge

  • Admin Support Member
  • *****
  • Posts: 3751
    • Oxygen Basic
Re: Translate C code to O2
« Reply #1 on: July 12, 2018, 06:25:38 AM »
Hi Alex,

This is all new to me.

In the context of creating a VST host which I'm assuming is cdecl:

Code: [Select]
'http://teragonaudio.com/article/How-to-make-your-own-VST-host.html

'typedef VstIntPtr (VSTCALLBACK *audioMasterCallback) (
' AEffect* effect,
' VstInt32 opcode,
' VstInt32 index,
'  VstIntPtr value,
' void* ptr,
' float opt);

extern cdecl

function HostCallback (
=====================
  AEffect* effect,
  VstInt32 opcode,
  VstInt32 index,
  VstIntPtr value,
  void* ptr,
  float opt
 ) as sys, callback
 ...
end function

end extern

...
'@HostCallback

string vstPath="..." 'specify pathname
sys VST=LoadLibrary(vstPath)
sys p=GetProcAddress(VST,"VSTPluginMain")
sys plugin = call p(@HostCallback) 'passing address of your main callback
...

I hope this helps

Alex_Longard

  • Newbie
  • *
  • Posts: 20
Re: Translate C code to O2
« Reply #2 on: July 12, 2018, 07:19:54 AM »
Hello Charles!
Thanks for your code.
I try to write vst plugin in Oxygen, i have some ideas for write this, only i not translate "AudioMasterCallback" and "Dispatcher" functions.

In attached file assembler test plugin written on Fasm.

Alex_Longard

  • Newbie
  • *
  • Posts: 20
Re: Translate C code to O2
« Reply #3 on: July 16, 2018, 12:56:48 PM »
Hi Charles!
It's possible to make function as field in structure?

For example:
Code: [Select]
Type mytype
int a
int b

Function myfunc(int a, int b)
return a+b
End Function
End Type

Charles Pegge

  • Admin Support Member
  • *****
  • Posts: 3751
    • Oxygen Basic
Re: Translate C code to O2
« Reply #4 on: July 16, 2018, 01:26:03 PM »
Hi Alex,

This is the simplest form of o2 OOP:

Code: [Select]
class mytype

  int a
  int b

  Function myfunc() as int
  return a+b
  End Function

end class

mytype t
t.a=1
t.b=2
print t.myfunc()

Alex_Longard

  • Newbie
  • *
  • Posts: 20
Re: Translate C code to O2
« Reply #5 on: July 16, 2018, 08:08:29 PM »
Good morning Charles,
Thanks for your code, i will try this.