==============================================================================
Program modifications for USB
10.09.25 jmb

Note: une partie du programme utilise des fonctions USB de Colin Granville
==============================================================================
Note the program imports a library: LIBRARY "<ProSound$Dir>.ProLib"

  The program now accepts parameters provided by the file !Run
ex :
Run <RecordAPI$Dir>.!RunImage 48000 2 16 130 5766 1973 -n"H1essential"
Certaines procdures ont t empruntes  Steve Drain.

The USB initialization part is in the PROCParam procedure



Fonctions/PROC USB:    (en fin du programme)
   DEF PROCusb_control(bmRType%,bRequest%,wValue%,wIndex%,wLength%,buf%)
   DEF PROCusb_endpointControl(dir%,req%,feature%,len%,buf%)
   DEF FNusb_findDeviceByVendor(vendor%,product%,version%)
   DEFPROCFindUSBDevices



Procedures/functions not affected:

  Main loop 
  DEFPROCError
  DEFPROCLog(a$)
  DEFPROCProSoundMsg(msg%)   (many coms from Henrik)
  DEFPROCDeregisterDevices
  DEFPROCRecordPoll
  DEFPROCRecordStop
  DEFPROCBroadcastMsg(msg%)


Modifications
buffers size to experiment.

  DEFPROCRecordStart(msg%)
 If there is a USB device, opening the flow from the device

note:With !Resrec we can see the allocation of the handle of the flow when recording:

devices#nopad;noblock; interface2;alternate1;enpoint 132, samplerate44100 sample size4; size 131072
Which corresponds to the configuration in this procedure

  size = USB buffer size required
  f you change the sample freq, it is well taken into account, as well as the endpoint address.
All these parameters are affected in DEFPROCFindUSBDevices 
xEndpoint% ,  xSamplerate% ,xSamplesize%, xChannels% and xBits%

but not  xInterface% et xAlternate% .... to test.

  DEFPROCEnumerateDevices(msg%)
  Prosound will only use a single USB device if it exists, and get the USB name

  DEFPROCSendMsg(msg%)

  DEFPROCFillBuffer(PSbuf%, start%, numsamples%, chn%)
 
   For information, default waveforms are line 42, to comment ...

   There will still be a lot of comments ... (those of Henrik)


Procedure information:

 DEFPROCFindUSBDevices

Must check that the product and its vendor exist. If yes, get the USBXX name and the settings are initialized to the value passed by !Run.

The sample frequency used does not need to be set out here, it is made in Record Start when the pipe opened.
This pipe is only open in the recording sequences.

Jean-Michel

   