Recent Posts

Pages: 1 2 3 4 5 6 7 8 9 10
1
OxygenBasic Examples / Re: Playing with the Beep function
« Last post by Roland Stowasser on Yesterday at 02:40:58 PM »
Hi Charles,

apparently I need to learn a bit more about midi to create effective tones. I don't quite understand the parameters for midiOutShortMsg in particular. But I found an old app that still works after some small tweaks. I believe it contains all the necessary functions I need. But I need to read the explanations a little more carefully.

Code: [Select]
/*---------------------------------------------------
   BACHTOCC.o2bas -- Bach Toccata in D Minor (First Bar)
                 (c) Charles Petzold, 1998
  ---------------------------------------------------*/
'Ported to Oxygenbasic

$ filename "BACHTOCC.exe"

'uses rtl32
'uses rtl64

uses corewin

'uses minmidi
'octave 0..10
extern lib "Winmm.dll"

sys midiOutOpen(sys *phmo, uDeviceID,dwCallback, dwInstance,fdwOpen)
sys midiOutShortMsg( sys hmo, dwMsg)
sys midiOutClose( sys hmo)
sys midiOutReset(sys hmo)

% COLOR_WINDOW = 5
% MIDIMAPPER = 0xFFFFFFFF

'=======================
'MAIN CODE
'=======================

sys hInstance = GetModuleHandle(0)
'========================================'


string szClassName = "BachTocc"
string WindowTitle = "Bach Toccata in D Minor (First Bar)"


% ID_TIMER = 1


function MidiOutMsg(sys hMidi, int iStatus, iChannel, iData1,  iData2) as dword
   dword dwMessage = iStatus + iChannel + (iData1 * 0x100) + (iData2 * 0x10000)
   return midiOutShortMsg(hMidi, dwMessage)
end function


int iDur = 1
int iNote = 2

int noteseq[] =
                {110, 69, 81, 
                 110, 67, 79,
                 990, 69, 81,
                 220, -1, -1,
                 110, 67, 79,
                 110, 65, 77,
                 110, 64, 76,
                 110, 62, 74,
                 220, 61, 73,
                 440, 62, 74,
                 1980,-1, -1,
                 110, 57, 69,
                 110, 55, 67,
                 990, 57, 69,
                 220, -1, -1,
                 220, 52, 64,
                 220, 53, 65,
                 220, 49, 61,
                 440, 50, 62,
                 1980, -1, -1}

sys hMidiOut
int iIndex = 1


function WndProc(sys hwnd, Message, wParam, lParam) as sys callback
   int i

   switch Message

   case WM_CREATE

     // Open MIDIMAPPER device                                                           
     if midiOutOpen(hMidiOut, MIDIMAPPER, 0, 0, 0) then
        MessageBeep(MB_ICONEXCLAMATION)
        MessageBox(hwnd, "Cannot open MIDI output device!",
                   szClassname, MB_ICONEXCLAMATION or MB_OK)
        return -1
     end if

     // Send Program Change messages for "Church Organ"         
     'MidiOutMsg(hMidiOut, 0xC0,  0, 19, 0)
     'Send Program Change messages for "Piccolo"         
     MidiOutMsg(hMidiOut, 0xC0,  0, 72, 0)
     SetTimer(hwnd, ID_TIMER, 1000, NULL)

   case WM_TIMER

     // Loop for 2-note polyphony         
     for i = 1 to 2                         
        // Note Off messages for previous note
        if iIndex <> 1 and noteseq[iIndex-iDur-iNote + i] <> -1 then
           MidiOutMsg(hMidiOut, 0x80,  0,
                      noteseq[iIndex-iDur-iNote +i], 0)
        end if
        // Note On messages for new note
        if iIndex <= 20*(iDur+iNote)  and
                     noteseq[iIndex +i] <> -1 then
           MidiOutMsg(hMidiOut, 0x90,  0,
                      noteseq[iIndex +i], 127)
        end if                             
     next i

     if iIndex <= 20*(iDur+iNote) then
       SetTimer(hwnd, ID_TIMER, noteseq[iIndex] - 1, NULL)
       iIndex = iIndex + iDur + iNote
     else
       KillTimer(hwnd, ID_TIMER)
       DestroyWindow (hwnd)   
     end if

   case WM_DESTROY
       midiOutReset(hMidiOut)
       midiOutClose(hMidiOut)
       PostQuitMessage(0)

   case else
       return DefWindowProc(hwnd, Message, wParam, lParam)

   end switch

   return 0
end function


function WinMain(sys nCmdShow) as sys

   WNDCLASSEX wc
   MSG Msg

   sys hwnd

   wc.cbSize        = sizeof(WNDCLASSEX)
   wc.style         = 0
   wc.lpfnWndProc   = @WndProc
   wc.cbClsExtra    = 0
   wc.cbWndExtra    = 0
   wc.hInstance     = hInstance
   wc.hIcon         = LoadIcon (NULL, IDI_APPLICATION)
   wc.hCursor       = LoadCursor(NULL, IDC_ARROW)
   wc.hbrBackground = COLOR_WINDOW+1
   wc.lpszMenuName  = NULL
   wc.lpszClassName = strptr(szClassName)
   wc.hIconSm       = LoadIcon (NULL, IDI_APPLICATION)

   if not RegisterClassEx(&wc) then
      MessageBox(NULL, "Window Registration Failed!", "Error!", MB_ICONERROR)
      return 0
   end if

   hwnd = CreateWindowEx(
              WS_EX_CLIENTEDGE,
              szClassName,
              WindowTitle,
              WS_OVERLAPPEDWINDOW,
              CW_USEDEFAULT, CW_USEDEFAULT, // x, y positon
                       500,           300,  // x size, y size
              NULL,
              NULL,   // window menu handle
              hInstance, NULL)

   if hwnd = NULL then
     MessageBox(NULL, "Window Creation Failed!", "Error!", MB_ICONERROR)
     return 0
   end if

   ShowWindow(hwnd, nCmdShow)
   UpdateWindow(hwnd)

   sys bRet
   do while (bRet := GetMessage(&Msg, NULL, 0, 0))
       TranslateMessage(&Msg)
       DispatchMessage(&Msg)
   wend
   
   return Msg.wParam
end function

'WINDOWS START
'=============

WinMain(SW_NORMAL)
2
OxygenBasic / Re: web navigation O2
« Last post by Zlatko Vid on January 26, 2023, 10:27:20 PM »
oh snap...i found this :
Quote
In Windows, the implementation uses the IupOleControl to embed an instance of the Internet Explorer WebBrowser control. A listener interface is used to capture and handle events using the Active Template Library (ATL) classes.

so Iup use ATL ...hmmm
3
OxygenBasic / Re: web navigation O2
« Last post by Zlatko Vid on January 26, 2023, 09:18:00 PM »
Hi Charles

thanks on that ..i know for this ATL

but i am interested in Iup..
Iup have some good capabilities about web control
as far as i remember ...i will peek into jrs forum maybe i there something useful
4
OxygenBasic / Re: web navigation O2
« Last post by Charles Pegge on January 26, 2023, 08:20:35 PM »
Hi Aurel,

There are 2 ATL examples in demos\!ProjB\ATL\

They use a version of your awinh.

I've fixed the URL for o2

Code: [Select]
'gui-skeleton app
$ Filename "t.exe"
'uses RTL64
uses COM\COMutil
uses WebBrowserAtl
uses awinh


#lookahead
INT win,win2
INT x,y,w,h,x2,y2,w2,h2
x=0:y=10:w=800:h=600
x2=410:y2=10:w2=400:h2=300
INT winstyle,wstyle2,wbstyle
winstyle = WS_MINMAXSIZE or WS_CLIPCHILDREN
wbstyle = WS_CHILD or WS_VISIBLE or WS_BORDER or WS_VSCROLL or WS_HSCROLL
INT btt0,btt1,btt2
INT b0ID = 100, b1ID=101, b2ID=102


% WM_FORWARDMSG = &H37F ' (895)

% IDB_BACK = 1001
% IDB_FWRD = 1002
% IDB_NAVG = 1003
% IDC_URL  = 1004
% IDC_WB   = 1005

'extern lib "ATL.dll"
'! AtlAxWinInit() as int
''! AtlAxWinTerm() as int
'! AtlAxGetControl( sys hWnd, pp ) as int
'end extern

int hWb

AtlAxWinInit()

'create window
'
win = SetWindow("ATL:Browser",x,y,w,h,0,winstyle)

'create buttons
int style=WS_CHILD | BS_TEXT ! BS_PUSHBOX | WS_VISIBLE
btt0=CreateWindowEx(0,"button", "O2", style,  64,4,30,30,  win, b0ID, 0, null)
btt1=CreateWindowEx(0,"button", "<--", style,  98,4,30,30, win, b1ID, 0, null)
btt2=CreateWindowEx(0,"button", "-->", style, 134,4,30,30, win, b2ID, 0, null)



'create browser window
hWb = CreateWindowEx(0, "AtlAxWin", "www.google.com",wbstyle , 64, 40, w-100,(h-56)-64, win, IDC_WB, 0, 0)
'iwebbrowser2 interface
'https://docs.microsoft.com/en-us/previous-versions/windows/internet-explorer/ie-developer/platform-apis/aa752127(v=vs.85)
'exdisp.h
IUnknown *v
int er=AtlAxGetControl  ( hwb, @@v )
CreateGuid g1 "EAB22AC1-30C1-11CF-A7EB-0000C05BAE0B" 'WebBrowser interface
CreateGuid g2 "D30C1661-CDAF-11d0-8A3E-00C04FC9E26E" 'WebBrowser2 interface
IWebBrowser2 *po
er=v.QueryInterface(g2,byval @@po)
v.Release
@v=0

wait()

'close
po.Release
'AtlAxWinTerm()
=0
end

function WndProc (sys hwnd,wmsg,wparam,lparam) as sys callback
==============================================================
select hwnd

case win

  select wmsg
  '
  case WM_CLOSE
    DestroyWindow win
    PostQuitMessage 0
  case WM_SIZE
    GetSize(win,0,0,w,h)
    MoveWindow(hWb,64, 40, w-100,(h-56)-64,1)
  case WM_COMMAND
    controlID = LoWord(wParam) 'get control ID
    notifyCode = HiWord(wParam) 'get notification message
    '
    select controlID
    '
    case b0ID
      if notifycode=0
        'short a=3         
        'er=po.get_StatusBar(@a)
        'print a
        'po.put_StatusBar(0)
        wbstring s="http://www.jose.it-berater.org/smfforum/index.php?board=154.0"
        er=po.Navigate s,0,0,0,0
        'er=po.get_LocationURL @s
        'er=po.get_LocationName @s
        'er=po.get_Name @s
        'er=po.get_FullName @s
        'print  " " er ", " s
        'frees s
        sys h
        'po.get_HWND @h
        po.get_Width @h
        po.put_Left 100
        'print h
        'po.Refresh
      end if     
    case b1ID
      if notifycode=0         
        po.GoBack
      end if
    case b2ID
      if notifycode=0         
        po.GoForward
      end if
       'po.Quit
       po.put_FullScreen 0xffff
       'po.put_Visible 0
       'po.goHome
    end select
  end select
end select

return default

end function

I've withdrawn IUP - the header file needs fixing.
5
OxygenBasic / Re: web navigation O2
« Last post by Zlatko Vid on January 26, 2023, 05:20:20 PM »
This is a old post and i look again into this Iup examples

no one of them is about web browser or Iup html control
i can bet that is see something similar JRS made using o2 or i am wrong

Iup looks like a easiest way to make WebBrowser program?
what you think?
6
General Discussion / Stats on Excess Deaths in 2022
« Last post by Charles Pegge on January 26, 2023, 06:55:16 AM »
Excess deaths in young adults, 2022 data
Dr. John Campbell
Jan 21, 2023
https://www.youtube.com/watch?v=OD0na_NZaLM
-->
European excess deaths, official data
Dr. John Campbell
https://www.youtube.com/watch?v=ku2Fv7xnL1o

other than covid infections
7
General Discussion / Drs Call For Government Investigation of mRNA Vaccines
« Last post by Charles Pegge on January 26, 2023, 06:28:48 AM »
UK Doctors Call For Government Investigation of mRNA COVID Vaccines
Christopher Norris
Jan 13, 2023
https://www.youtube.com/watch?v=_nIMhKA8jFY


British regulators limit covid vaccines
Dr. John Campbell
Jan 25, 2023
https://www.youtube.com/watch?v=sidjKoHS6NE

regulators / money from industry
8
OxygenBasic Examples / Re: Playing with the Beep function
« Last post by Charles Pegge on January 25, 2023, 06:42:43 PM »

I found there are system latencies wich make a wave-based beep function impractical, unfortunately. Perhaps using a midi sound, like the piccolo would make a much easier beep function.
9
OxygenBasic Examples / Re: Playing with the Beep function
« Last post by Charles Pegge on January 24, 2023, 07:04:34 AM »
This might be a useful template, based on demos/!ProjA/AudioSynth/WaveSynthDem7.o2bas

It produces a simple rising pitch from 100 Hz to 22050 Hz.

To avoid 'popping' a beep should delay its ending until phase is at a small value, ideally zero.

Alternatively, the beep could be faded out over a short period, say 50ms.

Code: [Select]
  uses minwin
  uses waves.h
  uses waves.inc
  '
  WaveOut w
  '
  w.WavoStart
  '
  double v
  '
  single a,amp,freq,nfreq,basefreq,phase,phdis,vphase
  single reverba=0.0, nreverba=1.0
  single ,filt,filtpr,filtba
  '
  sys b,bufo,d1,d2,i,p,q,decay,reverbt
  sys k1,k2,pc,opc,pcf,qq
  '
  /*
  'REVERB SETTINGS

  reverba=.25
  nreverba=.75
  'reverbt=0.3*88200 'max buffersize 64k
  */
  '

  amp=1000
  basefreq=100
  freq=basefreq
  filtba=1
  do
    sleep 5 'msec
    if GetAsyncKeyState 27 'escape key
      exit do
    endif
    p=w.wavopos
    if p+2000>q 'ahead ~1/40 sec

  '
  'ENVELOPE
  '
  int i
  '
  ============================
  for i=1 to 1000 'in envelope
  ============================
  '
  'DECAY
  '
  if amp>=1000 then decay=1
  if decay
    'amp*=.9995
    'if amp then amp-=.5
  else
    'amp+=10
  endif
  '
  v=freq*q*ipuls-phdis
  phase=frac(v)
  pc=v-phase 'wave counter
  if pcf then opc=pc : pcf=0
  '
  'NEW WAVE OR PULSE
  '
  if pc>opc then
    pcf=1
    vphase=frac(8*ipuls*q)
    'basefreq+=.02
    freq=basefreq
    '
    /*
    'VIBRATO (frequency modulation)
    '
    v=sin(pi2*vphase)*basefreq*.1
    freq+=v
    */
    '
    'SYNC PHASE
    '
    phdis=frac(freq*q*ipuls)-phase
    '
  end if
  '
  '
  'WAVEFORM
  '
  'a+=amp*noiseInterp(pc,phase)
  'a+=amp*sawtooth(phase)
  'a+=amp*triangle(phase)
  'a+=amp*square(phase)
  'a+=amp*square(phase*1.5)
  a+=amp*sin(pi2*phase) 'sine wave
  'a+=amp*sin(pi2*phase*2) 'sine harmonic
  'a+=amp*sin(pi2*phase*3) 'sine harmonic
  'a+=amp*sin(pi2*phase*4) 'sine harmonic

  '
  /*
  'FILTER
  '
  filtpr=.1
  filt=filt*(1-filtpr)+a*filtpr
  single lp=filt       'low pass
  'hp=a-filt     'high pass
  'a=lp*filtba + hp*(1-filtba) 'moving filter mix
  'a=lp*2 'boosted
  */
  '
  /*
  'TREMOLO (amplitude modulation)
  '
  a=a*(0+(1+sin(pi2*vphase)))*.5
  */
  '
  '
  SendToBuffer 'macro
  a=0
  '
  =================
  next 'in envelope
  =================

  int dmx=2
  if ++d1=dmx 'raise-pitch event
    'decay=0
    'amp=4000
    basefreq=freq*(1.0+0.00625*dmx) 'rising pitch
    'if basefreq>1000 then amp*=.90 'FADE
    if basefreq>22050 then exit do 'FINISH
    if ++d2=8
      d2=0
      'if filtba<=0 then exit do
    endif
    d1=0
  endif

  endif

  enddo
  '
  w.WavoEnd

   
10
OxygenBasic Examples / Re: Playing with the Beep function
« Last post by Roland Stowasser on January 23, 2023, 11:52:42 PM »
Hi Charles,

that's what I'm going to try to do. I noticed that you have already done some sound experiments in demos\!ProjA\AudioSynth. Maybe I can use some functions from the demos, that would simplify things a bit.

Pages: 1 2 3 4 5 6 7 8 9 10