کنترل صدا توسط Lingo

0012

Member
کنترل صدا توسط Lingo
وقتی که یک فایل صدا را در برنامه دایرکتور Import می کنیم ، می توانیم آنرا از طریق لینگو و یا از طریق خود برنامه کنترل کنیم .
اولین دستوری که در این درس به آن می پردازیم دستور Play است . این دستور به این صورت استفاده می شود :
Sound(ChannelNum).Play ( )
Sound(ChannelNum).Play ( Member(WhichMember) )
دستور اول صدایی را که در یکی از کانالهای صدای روی Score قرار دارد را اجرا می کند . دستور دوم یک Member از نوع صدا را اجرا می کند بدون اینکه در Score قرار داشته باشد .
توسط Lingo ما می توانیم یک فایل صدای خارجی را اجرا نماییم . یعنی یک فایل را که داخل برنامه وجود ندارد را بدون Import کردن ، اجرا نمایم . این فایل می تواند Mp3 ، Wave ، Aiff ، Swa باشد . این دستور به این صورت نوشته می شود :
Sound PlayFile WhichChannel , WhichFile
در اینجا چند مثال از این دستورات را مشاهده می کنیم :
Sound(1).play ( )
این دستور باعث می شود صدایی که در کانال یک صدای Score قرار دارد اجرا شود .
Sound(2).play (member "Sound-beep")
توسط این دستور member با نام Soudn-beep که یک صدای Importشدا است از طریق کانال دو صدا پخش می شود .
sound playfile 3,"c:\my sound\sound 01.mp3"
توسط این دستور فایل صدا به نام Sound 01.mp3 که مسیر آنرا وارد کردیم از طریق کانال 3 صدا پخش می شود .
حالا که با دستورات مربوط به اجرا و پخش صدا آشنا شدیم بهتره دستورات مربوط به توقف صدا رو هم با هم یاد بگیریم . برای توقف کامل یک صدا تنها یک دستور در دایرکتور وجود دازه که به این صورته :
sound(WhichChannel).Stop( )
توسط این دستور هر نوع از صدا از جمله صدای خارجی ، Member و Sprite را که از یک کانال صدا پخش می شوند را می توانیم متوقف کنیم .
دستور دیگری که جا داره اینجا بگیم Pause که باعث می شود صدا بطور موقت متوقف شود . این دستور هم به این صورت نوشته می شود :
Sound(WhichChannel).Pause( )
توسط این دستور می توانیم صدایی را که از طریق یکی از کانالهای صدا پخش می شود را Pause نماییم . دستور دیگری که در مورد کنترل صدا می تونیم استفاده کنیم Rewind است . این ستور به این صورت نوشته می شود .
Sound(WhichChannel).rewind ( )
اجرای این دستور باعث می شود که صدایی که از طریق یکی از کانالها پخش می شود ، متوقف شده و از ابتدا شروع به پخش نماید . اگر صدا Pause باشد در همان صورت باقی می ماند .
توسط Lingo ما می توانیم صدای یک کانال را کم و زیاد نماییم . بدین منطور از دستور زیر استفاده می کنیم .
Sound(WhichChannel).Volume = Value
مقدار صدا از 0 تا 255 تغییر می کند . به مثال زیر توجه کنید .
Sound(2).volume = 130
با اجرا ی این دستور صدایی که از طری کانال 2 پخش می شود با شدتی معادل نصف کم می شود .

منبع: www.openviewco.com
 

0012

Member
Vol

منظورت ررو واضح تر میگی
منظورت طراحی ولوم صدا
 
آخرین ویرایش:

0012

Member
اگه منظورت ساخت یه چیزی تو مایه های Windows Media Player (زمانی که فایل صوتی اجرا میکنی با تمام امکانتی که داره )میشه .باید با Directmedia Xtra فایل صوتی رو وارد کنی.اگه این اکسترا رو نداری لینکشو میتونی توی تایپکی که زدم (سایت های مربوط به دایرکتور) یه فایل گذاشتم که متونی دنلودش کنی آدرس هر xtra که بخواهی تقریبا توش هست به اگه خواستی کرکشو بهت میدم و در آخر اگه خواستی بهت میگم که چطور باید یه همچین چیزی درست کنی.
اگه منظورت رو متوجه نشدم باز هم بگو.
موفق باشی
 

mostafa_morteza

New Member
اکسترا را دارم ولی من می خواهم پنل را خودم طراخی کنم مثل پنل عقب و جلوبر صوت را
ممنون
اگر بگوید چگونه با این اکسترا می شود؟
 
  • Like
Reactions: Mds

0012

Member
اول یه اسکیپت باز کن و این کد ها رو به همین صورت توش بزار
-- DirectMedia Xtra Time Slider


-- based on the Video Time Slider from the behavior library version 1.1
-- Control

-- requires an 'extent' cast member
-- that limits the range the slider 'slides'
-- controls the currenttime of a DirectMedia Xtra sprite,
-- if the sprite is playing the slider moves automatically



property pDuration, pMovieTime, VideoSprite

property extentSprite
property hiliteMember -- looks like the handle plus hilite graphics
-- also holds the member of handle while hilited

property tracking
property newLocH
property newLocV

property dynamic -- if true and sending true, sends value while tracking

property min, max -- the range the slider maps to
property valrange -- the difference of max and min, set on begin
property minScreen, maxScreen -- calculated from the screen coords of the extent
property currentScreenVal -- the data point in screen coords, set in tracking
property extentlength -- in screen coords, set on begin

property CurrentVal

on getPropertyDescriptionList
if the currentspritenum = 0 then
set memdefault = 0
else
set memref = the member of sprite the currentspritenum
set memdefault = member (the membernum of member memref + 1)
end if


set description = []

addprop description, #VideoSprite, [#default 1, #format#integer, #comment "Video Sprite"]

addprop description, #extentSprite, [#default 1, #format#integer, #comment "Extent Sprite"]

addprop description, #hiliteMember, [#default memdefault , #format#graphic,#comment "Hilite Member"]


addprop description, #dynamic, [#default 1, #format#boolean,#comment "Dynamic"]

return description
end

on getBehaviorDescription
return "Drag to slider 'handle' to enable control of video play time. Requires additional 'extent' member which limits the handle travel range." & RETURN & "PARAMETERS" & RETURN & "• Video Sprite - Enter the number of sprite channel in which video is displayed." & RETURN & "• Extent Sprite - Enter the number of sprite channel that contains the 'extent' sprite." & RETURN & "• Hilite Member - Member to display while handle is being dragged." & RETURN & "• Dynamic - If set, video time will be updated while handle is dragged, else when handle is released."
end

on compute_val me
-- relies on tracking to update the currentScreenVal (different for Hor, Vert)
set val = 0.0
set val = float(the currentScreenVal of me) / float (the extentlength of me)
set val = val * the valrange of me
set val = val + the min of me
return val
end

on send_the_val me, val
-- sets the digital video time to the val * paramter {0 - movieduration}
set pMovieTime = val * pDuration
videoseek(sprite VideoSprite, pMovieTime)

end


on beginSprite me

set pDuration = the duration of sprite VideoSprite

set the min of me = 0.0
set the max of me = 1.0

--
set handle = the spritenum of me
set the tracking of me = FALSE
set the newLocH of me = the locH of sprite handle
set the newLocV of me = the locV of sprite handle


set the newLocV of me = the locV of sprite the extentSprite of me
set the minScreen of me = the left of sprite the extentSprite of me
set the maxScreen of me = the right of sprite the extentSprite of me


set the locH of sprite handle to the newLocH of me
set the locV of sprite handle to the newLocV of me

set the valrange of me = the max of me - the min of me
set the extentlength of me = the maxScreen of me - the minScreen of me

end

on prepareFrame me
-- limits motion of handle to extents of extentSprite
-- and locks the handle to the track of the extentSprite

if tracking then
set handle = the spriteNum of me
set extent = the extentSprite of me


set the newLocH of me = the mouseH
set the newLocV of me = the locV of sprite extent
if the newLocH of me < the left of sprite extent then
set the newLocH of me = the left of sprite extent
end if
if the newLocH of me > the right of sprite extent then
set the newLocH of me = the right of sprite extent
end if

set the currentScreenVal of me = the newLocH of me - the minScreen of me


set the locH of sprite handle to the newLocH of me
set the locV of sprite handle to the newLocV of me

if the dynamic of me then
send_the_val me, compute_val (me)
end if

else -- end if tracking, control slider position by movieTime

if (float(pDuration)=0) then
set pDuration = the duration of sprite VideoSprite
end if

if (float(pDuration)<>0) then
set x = float(the currenttime of sprite VideoSprite)/ float(pDuration)
end if

set handle = the spriteNum of me
set extent = the extentSprite of me

set ScreenX = the left of sprite extent + (x * (the right of sprite extent - the left of sprite extent))
set the newLocH of me = screenX
set the newLocV of me = the locV of sprite extent
if the newLocH of me < the left of sprite extent then
set the newLocH of me = the left of sprite extent
end if
if the newLocH of me > the right of sprite extent then
set the newLocH of me = the right of sprite extent
end if

set the currentScreenVal of me = the newLocH of me - the minScreen of me

set the locH of sprite handle to the newLocH of me
set the locV of sprite handle to the newLocV of me

end if


end

on mouseDown me
set tracking = TRUE
set temp = the member of sprite the spritenum of me
set the member of sprite the spritenum of me = member the hiliteMember of me
set the hiliteMember of me = temp
end

on mouseUp me
set tracking = FALSE
set temp = the member of sprite the spritenum of me
set the member of sprite the spritenum of me = member the hiliteMember of me
set the hiliteMember of me = temp

end

on mouseUpOutside me
set tracking = FALSE
set temp = the member of sprite the spritenum of me
set the member of sprite the spritenum of me = member the hiliteMember of me
set the hiliteMember of me = temp

end

برای ساخت Slider زمان هست که وقتی حالا میتونی این رو بکشی و روی کنترل کننده فایل بزاری خودش از دوتا کست میخواد و نام فایل تصویری یا صوتیکه داری.
بعدش برای ساخت دکمه ها یه اسکریپت دیگه باز کن(خالی خالی)و این کد ها رو توش بزار
--DirectMedia Xtra Controller Button

property videoSprite -- the sprite number that is getting controlled
property videoCommand -- the command to be issued
property standardImage -- the Button Image
property alternateImage -- the Rollover Image for the button
property clickedImage -- the Clicked Image for the button rollover and click.
property param1 -- first parameter of the command
property param2 -- second parameter of the command

on DoControl me
case ( the VideoCommand of me ) of
#Play
videoplay(sprite the videoSprite of me)
#Pause
videopause(sprite the videoSprite of me)
#Rewind
videoseek(sprite the videoSprite of me, the segmentstart of sprite the videoSprite of me)
#StepForward
videopause(sprite the videoSprite of me)
videoseek(sprite the videoSprite of me, the currenttime of sprite the videoSprite of me+30)
#StepBackward
videopause(sprite the videoSprite of me)
videoseek(sprite the videoSprite of me, the currenttime of sprite the videoSprite of me-30)
#Seek
videoseek(sprite the videoSprite of me, the param1 of me)
#PlaySegment
videoplaysegment(sprite the videoSprite of me, the param1 of me, the param2 of me)

end case
end


on mouseUp me
set the member of sprite the spritenum of me = the standardImage of me
DoControl me
end

on mouseDown me
set the member of sprite the spritenum of me = the clickedImage of me
end

on mouseEnter me
set the member of sprite the spritenum of me = the alternateImage of me
end

on mouseLeave me
set the member of sprite the spritenum of me = the standardImage of me
end

---

on beginSprite me
set the standardImage of me = the member of sprite the spriteNum of me
end

---

on getPropertyDescriptionList
if the currentspritenum = 0 then
set memdefault = 0
else
set memref = the member of sprite the currentspritenum
set castlibnum = the castlibnum of memref
set memdefault = member (the membernum of member memref + 1) of castlib castlibnum
set memdefault2 = member (the membernum of member memref + 2) of castlib castlibnum
end if

set p_list = [ #videoCommand [ #comment "Action",#format #symbol, #range [ #Play, #Pause, #Rewind,#StepBackward,#StepForward, #Seek, #PlaySegment],#default #Play ], #param1 [ #comment "First Parameter (Use with seek or playsegment)", #format #long, #default 0] , #param2 [ #comment "Second Parameter (Use with playsegment)", #format #long, #default 0] , #videoSprite [ #comment "DirectMedia Sprite Channel", #format #integer, #default 1] , #alternateImage [ #comment "Rollover Button Cast Member", #format #graphic, #default memdefault ], #clickedImage [ #comment "Clicked Button Cast Member", #format #graphic, #default memdefault2 ]]
return p_list
end

on getBehaviorDescription
return "Used to create Play, Pause, StepForward, StepBackward, Rewind, Seek and PlaySegment control buttons for a DirectMedia Xtra video sprite. You can also attach rollover and alternate images for the clicked buttons" & RETURN & "PARAMETERS" & RETURN & "Action - Choose the action to perform on mouseUP ( Play, Pause, Rewind, StepBackward, StepForward, Seek, PlaySegment )." & RETURN & "First Parameter if the Action is Seek than this parameter contains the seek to time (in milliseconds). For the PlaySegment action this parameter contains the starting time of the segment to play (in milliseconds)"& RETURN &"Second Parameter Used with the PlaySegment action. Contains the ending time of the segment to play (in milliseconds)"& RETURN &"DirectMedia Sprite Channel - Enter the number of sprite channel of the DirectMedia Xtra video that is being controlled."& RETURN &"Rollover Button the castmember that will be used as the rollover image of the button. Default is the castmember located just after the button castmember"& RETURN&"Clicked Button the castmember that will be used as the clicked image of the button. Default is the castmember located just after the rollover castmember"
end

این رو بکش و روی تمام دکمه های که میخوای بکش خودش بهت حق انتخواب میده که این دکمه بارت چه کاری انجام بده (جلو وعقب وشروع و استپ) توی سایتش هم چند تا نمونه و راهنما هم گذاشته که خلی مفید هستند
اگه مشکلی داشتی بگو.
 
  • Like
Reactions: Mds

mostafa_morteza

New Member
آقا شرمنده از اینکه شما را در زحمت انداخته ام
حرف شما متین ولی 1-جواب نداد کار شما (البته با این برداشتی که من داشتم )
2-در مورد این قضایا خدمت شما عرض کنم اگر یک مقدار راه را اصولی ومنظم تر بگوید من فکر می کنم بهتر باشد.
 

0012

Member
شرمند که نبودم خیلی سرم شلوغ بود یه فایل برات میفرستم اگه سوالی داشتی بگو.
 

mr mostafa

New Member
لطفا به من هم كمك كنيد(نوار لغزنده براي كنترل صدا)

با عرض سلام و خسته نباشيد
من هم مي خوام يك نوار لغزنده براي كنترل فايلهاي صوتي بسازم
لطفا اگه ميشه به من هم يك كمكي بكنيد
ممنون از همتون
 

mr mostafa

New Member
سلام و خسته نباشيد
من هم همين مشكلو دارم
توي برنامم چند تا فايل دارم كه مي خوام با كليك روي اونها فايلم پخش بشه
تا اينجا شو درست كردم كليدهاي اجرا و توقف هم داره ولي يك پنل صوت هم مي خواهم داشته باشه
تا با كليك روي فايلها با اوون پنل به هر جاي صدا رفت و صدا رو عقب و جلو كرد
لطفا كمكم كنيد
هم لازم داره لطفا به همراه يك فايل ساخته شده برام بفرستيدxtra اگر
پيشاپيش از همتون تشكر ميكنم
[email protected]
 

Mds

Active Member
سلام و ممنون از توضیحا تتون
اگر بتونید فایلش رو پیوست کنید ممنون میشم
 

Mds

Active Member
سلام و خسته نباشید.
اگر ممکن هست فالش رو پیوست کنید . ممنون
__________________
 
تو رو خدا كمك كنيد

من 2 تا اهنگ رو تو دايركتور وارد كردم و آهنگ اول آهنگ زمينه است

من مي خوام توي يه قسمتي از فيلم اهنگ اول به صورت pause در بياد و اهنگ دوم(روي كانال دوم) پخش بشه

تو رو خدا كدشو بگيد
 

mojtaba1339

Active Member
دوستان عزیز :
seyed ahmad mousavi
Mds
mr mostafa
جون من یه نگاه به تاریخ شروع تاپیک بندازین ، خداییش این تاپیکا رو بالا نیارین. اگه سوالی هست تو یه تاپیک جدید مطرح کنین.
با تشکر از همه دوستان
 
خوب اول دوتا صدا را در دایرکتور وارد کن
برای اینکه صدای اول شروع به خواندن کنه روش های زیادی وجود داره مثلا می تونی در فریم اول بنویسی
کد:
sound(1).play(member("S1"))
ابنجا فایل با نام S1 شروع به خواندن می کنه. بعد هر کجا خواستی صدای اول قطع بشه و صدای دوم پخش بشه بنویس
کد:
sound(2).play(member("S2"))
sound(1).pause()
اگه مشکلی بود بگو. موفق باشید. محمد کاوه
 

0012

Member
کنترل صدا

فایل New Folder.rar رو با نرم افزار WinRAR باید باز کنی بقیش توش توضیح دادم
موفق باشی
Xtras و کرکش و سمپل
 

جدیدترین ارسال ها

بالا