Page 1 of 1

SndPlaySound Virtual Guitar

PostPosted: Fri Aug 29, 2008 1:42 pm
by Lisa Giordano
Ciao a tutti
Mi sto divertendo a sviluppare una utility per chitarra che consente di suonare gli accordi memorizzando le progressioni, i vari accordi sono registrati in wav per cui uso SndPlaySound per suonarli.
Ora, vorrei aggiungere una base di Drum ma non so come eseguire contemporaneamente due SndPlaySound.
Help me

PostPosted: Sat Aug 30, 2008 9:25 am
by Antonio Linares
Lisa,

You may use a Timer to play the drums sound every time period.

Please review fwh\samples\TestTime.prg to review how to manage timers.

VGuitar

PostPosted: Sat Aug 30, 2008 12:33 pm
by Lisa Giordano
Questo esempio funziona perfettamente, l'inconveniente è che nella function giro(), SndPlaySound( "Accordi\Beat68.wav", 1 ) viene interrotta da SndPlaySound( "Accordi\"+aFile[t]+".wav", 1 ).
Io vorrei invece che rimanesse in esecuzione SndPlaySound( "Accordi\Beat68.wav", 1 ) in un loop, e che che nello tempo girasse
For t=1 to Len(aFile)
SndPlaySound( "Accordi\"+aFile[t]+".wav", 1 )
inkey(1)
Next t




#include "Fivewin.ch"


************************************************************************
Function Test()
Local oWnd, oMenu, oImg
Local oWC,oBar,oCursor
Local aFile:={}

DEFINE WINDOW oWnd FROM 0,0 TO 30,100 MENU oMenu TITLE "Virtual Guitar" MDI

DEFINE BUTTONBAR oBar SIZE 50,30 3DLOOK CURSOR oCursor OF oWnd

DEFINE BUTTON OF oBar PROMPT "Do+" ACTION(SndPlaySound( "Accordi\C+.wav", 1 ),aadd(aFile,"C+")) GROUP
DEFINE BUTTON OF oBar PROMPT "Re-" ACTION(SndPlaySound( "Accordi\D-.wav", 1 ),aadd(aFile,"D-")) GROUP
DEFINE BUTTON OF oBar PROMPT "Mi-" ACTION(SndPlaySound( "Accordi\E-.wav", 1 ),aadd(aFile,"E-")) GROUP
DEFINE BUTTON OF oBar PROMPT "Mi+" ACTION(SndPlaySound( "Accordi\E+.wav", 1 ),aadd(aFile,"E+")) GROUP
DEFINE BUTTON OF oBar PROMPT "Fa+" ACTION(SndPlaySound( "Accordi\F+.wav", 1 ),aadd(aFile,"F+")) GROUP
DEFINE BUTTON OF oBar PROMPT "Sol+" ACTION(SndPlaySound( "Accordi\G+.wav", 1 ),aadd(aFile,"G+")) GROUP
DEFINE BUTTON OF oBar PROMPT "La-" ACTION(SndPlaySound( "Accordi\A-.wav", ),aadd(aFile,"A-")) GROUP
DEFINE BUTTON OF oBar PROMPT " " GROUP
DEFINE BUTTON OF oBar PROMPT "Nuovo" ACTION (aFile:={}) GROUP
DEFINE BUTTON OF oBar PROMPT "Giro" ACTION (Giro(aFile)) GROUP
DEFINE BUTTON OF oBar PROMPT "Esci" ACTION (oWnd:End()) GROUP
ACTIVATE WINDOW oWnd

return nil

**********************************************************

Function Giro(aFile)
Local t,i
SndPlaySound( "Accordi\Beat68.wav", 1 )
For t=1 to Len(aFile)
SndPlaySound( "Accordi\"+aFile[t]+".wav", 1 )
inkey(1)
Next t
return nil

Ciao grazie

PostPosted: Sat Aug 30, 2008 12:50 pm
by Antonio Linares
Lisa,

Prueba a no usar 1 al llamar a SndPlaySound( ... ) // , 1 ) no

PostPosted: Sat Aug 30, 2008 12:57 pm
by Lisa Giordano
Antonio,

Ho provato ad usare tutti i parametri 0,1,2,4,8,16 e le varie combinazioni,
ma ma più sndplay non vengono eseguite contemporaneamente.
Il suono drum più chitarra non vengono eseguite insieme.
Ciao

PostPosted: Sat Aug 30, 2008 2:55 pm
by Antonio Linares
Lisa,

/*
* flag values for fuSound and fdwSound arguments on [snd]PlaySound
*/
#define SND_SYNC 0x0000 /* play synchronously (default) */
#define SND_ASYNC 0x0001 /* play asynchronously */
#define SND_NODEFAULT 0x0002 /* silence (!default) if sound not found */
#define SND_MEMORY 0x0004 /* pszSound points to a memory file */
#define SND_LOOP 0x0008 /* loop the sound until next sndPlaySound */
#define SND_NOSTOP 0x0010 /* don't stop any currently playing sound */

#define SND_NOWAIT 0x00002000L /* don't wait if the driver is busy */
#define SND_ALIAS 0x00010000L /* name is a registry alias */
#define SND_ALIAS_ID 0x00110000L /* alias is a predefined ID */
#define SND_FILENAME 0x00020000L /* name is file name */
#define SND_RESOURCE 0x00040004L /* name is resource name or atom */
#if(WINVER >= 0x0400)
#define SND_PURGE 0x0040 /* purge non-static events for task */
#define SND_APPLICATION 0x0080 /* look for application specific association

Maybe nOr( SND_ASYNC, SND_NOSTOP ) ?