2012年7月3日 星期二

[Puredata] workshop day1_gemkeyboard

1. 使用鍵盤操作畫面中的物體
Object,gemkeyboard,輸出值為數字,分別對應不同的鍵盤,此指令只可在gem視窗內使用
2. 使用select,區別不同鍵盤
  • Object,sel,後面輸入數字,比如sel 1 2,當輸入值為1或2,就會往下傳,下方會產生三個輸出值,從左開始為,輸入值為1、輸入值為2、輸入值非前面出現的選項
  • 若要使用鍵盤上下左右控制,即可使用sel 38 40 37 39


3. 使用unpack
  • 利用上下左右鍵控制物體位置,使用message輸入X、Y的位置,比如1 3,數字間要空格
  • Object,unpack,unpack可將1 3分別輸出1、3,f為浮點數




2012年7月2日 星期一

[Puredata] workshop day1_color

1. 使用color改變背景顏色

  • Message,color,後三個數字為RGB,範圍0~1,0為黑色,1為白色
  • 將color連到gemwin上即可變換顏色









2. 運用變數,動態改變背景顏色

  • 運用迴圈產生0~1的數值,使用0~100的迴圈再除以100,可取得0~1的小數點,單位是0.01
  • 在Pd中,變數使用$,比如變數1→$1,變數2→$2,x+y=5 → $1+$2=5
  • 在color中的R中使用$1,便可利用迴圈產生的數值動態改變R值













[Puredata] workshop day1_loop

1. 迴圈,不斷重複執行動作

  • Bang,Put/Bang,放置一個物件,點擊即執行
  • Object,f 1,f為float,此物件為1 的浮點數
  • 數值+ 1後,送回 f 繼續累加
  • 若要取某範圍內的數字不斷重複,需使用%取餘數,比如取10的餘數,%  10,即是不斷重複0~9
  • 在執行模式下,點擊bang,以下的數值便會不斷累加

2. 使用metro自動執行迴圈
  • Object,metro,後方數值為毫秒數,意指每毫秒執行一次,右方輸入端可動態輸入毫秒數
  • Toggle,Put/Toggle,開關,與metro搭配使用,點擊可開關,開啟時顯示X,關閉時顯示空白方格





[Puredata] workshop day1_translate

1. 使用translate改變circle的位置

  • 在gemhead跟中間加入translateXYZ,translateXYZ上方會有四個輸入端,左至右分別為觸發、X軸、Y軸、Z軸
  • 若無輸入數值,預設值為(0,0,0),也可靜態輸入預設值,值與值之間需有空白格,如translateXYZ 1 2 1,位置便為(1,2,1)
  • 使用Number便可動態變化位置

2. 取得滑鼠位置
  • Object,gemmouse,抓取滑鼠位置
  • gemmouse 1 2,將滑鼠抓取的x位置轉換為0~1,將滑鼠抓取的x位置轉換為0~2
  • gemmouse有五個輸出,由左至右為,X位置、Y位置、滑鼠左鍵是否按下、滑鼠中鍵是否按下、滑鼠右鍵是否按下

3. 使用滑鼠位置改變circle位置
  • 由於畫面最大最小值是由 4 ~ -4,因此需將gemmouse取得的值改為 4 ~ -4
  • Object,range,將數值縮放,range 0 1 4 -4,把0~1的數值,縮放到 4 ~ -4
  • gemmouse第一個、第二個輸出端,透過range,接到translateXYZ的X、Y中









[Puredata] workshop day1_gem

使用Puredata畫圖

1. 建立畫布

  • 使用Object,輸入gemwin,gemwin就是畫圖的方式,可以想像成主機
  • 使用Message,輸入create,1,當Message裡使用到逗號,便是傳出一個以上的訊息,比如1,43,65就是三個訊息,create是建立畫布,1就是開始算圖,想像成有了主機,若需使用仍要開機才可
  • 使用Message,輸入destroy,destroy為刪除畫布
  • 將create,1與destroy連結到gemwin
  • 開啟執行模式點選create即可建立,點選destory即可銷毀
  • 畫布最左方為 -4,最右方為 4,最上方為 4,最下方為 -4 




















































2. 畫圓形


  • 使用Object,輸入gemhead,一個演員需要表演需要舞台,而gemhead就是一個舞台
  • 使用Object,輸入circle,此指令可畫圓,預設半徑為1,也可自行輸入半徑,比如要半徑2的圓形,即輸入circle 2,circle與2中間需有空白格
  • circle上方有兩輸入端,左為執行,右為半徑






















































3. 動態改變圓形半徑


  • 使用Number,並將Number連結到circle



4. 利用麥克風聲音改變圓形半徑
  • Object,adc~,接收麥克風的值
  • Object,env~,將接收到的值輸出為0~100
  • 將麥克風取得的值,除以40,放入circle的半徑中,使之動態變化









[Puredata] workshop day1_hello world

簡單介紹:
Pd (全名 Pure Data)是一個即時圖形化編寫程式環境,針對音頻,視頻和圖形處理。
======================================================================

1. 開啟Pd後會出現console window(主控台,顯示偵錯狀態)

2. 開啟新檔案,選擇console window上方的File,選擇New。
    請勿將新開視窗放大到無法看到console window,以方便隨時檢查狀態。

3. Pd有兩種模式,編輯模式與執行模式
    編輯模式:滑鼠游標為手掌形狀
    執行模式:滑鼠游標為箭頭形狀
    切換方式:Edit / edit mode

4. 第一支小程式,Hellow world

切換至編輯模式
新增Object:Put/Object,Object為產生一行為
Object內打入print,若輸入錯誤邊框會出現紅線

新增Message,Message為送出參數
Message內打入文字,Pd目前只接受英文

5. Pd物件的上方均為輸入端,下方為輸出端
將Message的輸出端接到print的輸入端
切換到執行模式點選hello world
即可在console window看到hello world


6. Message為靜態輸入,若要使用動態輸入,需使用Number,File / Number
切換到執行模式,以左鍵持續按著Number上下拖曳即可改變數值,並不斷地在console window顯示




2012年6月13日 星期三

[Processing] C:\processing-1.2.1\libraries\JMyron\library\JMyron.dll: Can't find dependent libraries



A tip for Windows 7 users, from lgfa321:
If you are getting this error when you try to run: processing.app.debug.RunnerException: UnsatisfiedLinkError: D:\Software\processing-1.2.1\libraries\JMyron\library\JMyron.dll: Can't find dependent libraries:

"Reason : Windows 7 doesn't come with MicroSoft C libraries, which were normally include in the other (older) Windoes system.
This means there are two files missing in the Windows 7 system: MSVCP71.DLL and Msvcr71.dll
Solution : Download these two files from here:
http://www.addictivetips.com/?attachment_id=38105
AND!
For Windows 7 32-bit OS: put both dll files inside Windows/System32 folder
For Windows 7 64-bit OS: put both dll files inside Windows/SysWOW64 folder."



Setup Instructions for OSX 10.7 Lion (from AaronW):
  1. Unzip and Install the Arduino IDE v1.0 for OSX into your applications folder.
  2. Unzip and Install the Processing IDE v1.5.1 for OSX into your applications folder.
  3. Run the Arduino IDE,( I was prompted to automatically download and install a Java runtime as this was run on a clean install of OSX).
  4. Run the Processing IDE, and close it again.
  5. Check that there is now an “arduino” and “processing” folder in your user “Documents” folder
  6. Download Code Version 6.02.zip from the Project Sentry Gun Website.
  7. Extract the zip file and open “Code Version 6.02.zip/Arduino Code/Turrett_06_02/Turret_06_02.ino”,in the Arduino IDE, upload to your Arduino controller.
  8. Copy the “Code Version 6.02.zip/Processing code/libraries” folder to your user “Documents /Processing” folder.
  9. Download libJMyron.jnilib compiled for intel macs from http://jibberia.com/projects and use it to replace the libJMyron.jnilib currently located in your user “Documents/Processing/libraries/JMyron/library” folder.
  10. Run the Processing IDE and load “Code Version 6.02.zip/Processing code/Turrret_06_02/Turret_06_02.pde”.
  11. Click Run.