How to create staccato guitar sound with midi?

Just starting out? Need help? Post your questions and find answers here.
Cor
Enthusiast
Enthusiast
Posts: 124
Joined: Fri Apr 25, 2003 7:52 pm
Location: Netherlands
Contact:

How to create staccato guitar sound with midi?

Post by Cor »

Has someone some midi tricks to play the following notes as mentioned in the source:

Play notes as staccato
Play notes as muted

Thanks in advance

Code: Select all

Global hMidiOut
#Acoustic_Steel_Guitar = 25
#Channel1 = 1
#Channel2 = 2
#Channel3 = 3
#Channel4 = 4
#Channel5 = 5
#Channel6 = 6


Procedure MidiOutMessage(hMidi,iStatus,iChannel,iData1,iData2)
  dwMessage = iStatus | iChannel | (iData1 << 8 ) | (iData2 << 16)
  ProcedureReturn midiOutShortMsg_(hMidi, dwMessage) ;
EndProcedure

Procedure SetInstrument(channel,instrument)
  MidiOutMessage(hMidiOut, $C0,  channel, instrument, 0)
EndProcedure

Procedure PlayNote(channel,Note,velocity)
  MidiOutMessage(hMidiOut, $90, channel, Note , velocity)
EndProcedure


Procedure StopNote(channel,Note)
  MidiOutMessage(hMidiOut, $90, channel, Note , 0)
EndProcedure

midi.MIDIOUTCAPS
devices = midiOutGetNumDevs_()

For devnum=-1 To devices-1
  If midiOutGetDevCaps_(devnum,@midi,SizeOf(MIDIOUTCAPS))=0
    If midi\wVoices >0
    midiport=devnum
    EndIf
  EndIf
Next

*hMidiOut.l
If midiOutOpen_(@hMidiOut,midiport,0,0,0) = #MMSYSERR_NOERROR
; set acoustic steel guitar as instrument
  SetInstrument(#Channel1,#Acoustic_Steel_Guitar)
  SetInstrument(#Channel2,#Acoustic_Steel_Guitar)
  SetInstrument(#Channel3,#Acoustic_Steel_Guitar)
  SetInstrument(#Channel4,#Acoustic_Steel_Guitar)
  

For  cnt = 1 To 5
; normal sound
PlayNote(#Channel1,$2D,63)
PlayNote(#Channel2,$39,63)
PlayNote(#Channel3,$3C,63)
PlayNote(#Channel4,$40,63)


Delay (2000)
StopNote(#Channel1,$2D)
StopNote(#Channel2,$39)
StopNote(#Channel3,$3C)
StopNote(#Channel3,$40)

; this must be a staccato sound
PlayNote(#Channel1,$39,90)
PlayNote(#Channel2,$3C,90)
PlayNote(#Channel3,$40,90)

Delay (300)
StopNote(#Channel1,$39)
StopNote(#Channel2,$3C)
StopNote(#Channel3,$40)

; this must be a muted sound
PlayNote(#Channel1,$2D,40)
PlayNote(#Channel2,$30,40)
PlayNote(#Channel3,$34,40)

Delay (300)
StopNote(#Channel1,$2D)
StopNote(#Channel2,$30)
StopNote(#Channel3,$34 )
 

Next 

; end: reset instruments to 0 (default)
SetInstrument(#Channel1,0)
SetInstrument(#Channel2,0)
SetInstrument(#Channel3,0)
SetInstrument(#Channel4,0)

; end: close MIDI output
midiOutClose_(hMidiOut)
EndIf
End


Cor de Visser

Registered PureBasic user

Author of ChordPlanet
Made with PureBasic
http://www.chordplanet.com
User avatar
einander
Enthusiast
Enthusiast
Posts: 744
Joined: Thu Jun 26, 2003 2:09 am
Location: Spain (Galicia)

Post by einander »

Cor:
For a short staccato, try Velocity=100, Lenght= 100, and compensate the shorter lenght with Delay(200) after StopNote.
For Muted, try Velocity=80, Lenght=15, compensation Delay(285).


New chord loop:

Code: Select all

For  cnt = 1 To 5 
; normal sound 

PlayNote(#Channel1,$2D,63) 
PlayNote(#Channel2,$39,63) 
PlayNote(#Channel3,$3C,63) 
PlayNote(#Channel4,$40,63) 

Delay (2000) 
StopNote(#Channel1,$2D) 
StopNote(#Channel2,$39) 
StopNote(#Channel3,$3C) 
StopNote(#Channel3,$40) 

; this must be a staccato sound 
PlayNote(#Channel1,$39,100)   ; increase velocity  
PlayNote(#Channel2,$3C,100) 
PlayNote(#Channel3,$40,100) 

Delay (100) ; shorten lenght
StopNote(#Channel1,$39) 
StopNote(#Channel2,$3C) 
StopNote(#Channel3,$40) 
Delay(200)     ; compensate lenght

; this must be a muted sound         
PlayNote(#Channel1,$2D,80) ;  velocity 80 
PlayNote(#Channel2,$30,80) 
PlayNote(#Channel3,$34,80) 
Delay (15)     ;very short lenght

StopNote(#Channel1,$2D) 
StopNote(#Channel2,$30) 
StopNote(#Channel3,$34 ) 
Delay(285)    ;compensate lenght

Next 
AZJIO
Addict
Addict
Posts: 2154
Joined: Sun May 14, 2017 1:48 am

Re: How to create staccato guitar sound with midi?

Post by AZJIO »

Midi_Beep.7z
Europe
Heavy Asia
Nikkolo Paganini
Tico-Tico
Johan Bach
Oginsky polonaise

Code: Select all

Procedure _Beep(nota,octave=4,Duration=200,pause=0)
	Protected Frequency
	nota=nota+Tone+12*octave
	; 	$90 + (nota   * 256)
	MidiOutMessage(hMidiOut, $90, #Channel1, nota , volume)
	Delay(Duration/temp)
	MidiOutMessage(hMidiOut, $90, #Channel1, nota , 0)
	If pause<>0
		Delay(pause/temp)
	EndIf
EndProcedure

_Beep(1,6,100)
_Beep(4,5,100)
_Beep(3,5,100)
_Beep(4,5,100)
_Beep(1,5,100)
_Beep(4,5,100)
_Beep(3,5,100)
_Beep(4,5,100)
I did it a long time ago

or so

Code: Select all

Global t=1 ; коэффициент темпа
Global f=1  ; коэффициент частоты

Procedure _Beep(nota,Octave=4,Duration=200,pause=0)
	Protected Frequency
	Frequency=440*Pow(2 , nota/12+Octave+1/6-4)
	Beep_(Frequency*f, Duration/t)
	If pause<>0
		Delay(pause/t)
	EndIf
EndProcedure

_Beep(7,5,130)
_Beep(2,5,130)
_Beep(7,5,130)
_Beep(2,5,130)
_Beep(7,5,130)
_Beep(6,5,130)
_Beep(6,5,260)

_Beep(6,5,130)
_Beep(2,5,130)
_Beep(6,5,130)
_Beep(2,5,130)
_Beep(6,5,130)
_Beep(7,5,130)
_Beep(7,5,260)
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5494
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Re: How to create staccato guitar sound with midi?

Post by Kwai chang caine »

Waouuuh !! what a lots of works :shock:
I don't know if you use your own software for create the sources, but i have listening all and find it very nices :D
Nearly i have danced behind my desktop :lol:
Thanks for sharing 8)
ImageThe happiness is a road...
Not a destination
Post Reply