2012年6月27日水曜日

Ruby1.9.3[i386-mingw32] + wincom RS-232Cターミナル


TEXCELL Rubyシリアル通信ライブラリ(Windows)を使用して作ってみた。
SD-RDLoopbackでテストした。

C:\rubyapi\ci-v>ruby -v
ruby 1.9.3p194 (2012-04-20) [i386-mingw32]

C:\rubyapi\ci-v>type wincom_s2_20120622.rb
# -*- coding: shift_jis -*-
require "./wincom"      #ruby1.9.3 only
require 'dl/import'

module MSVCRT           #ruby-list:42280 kara
    extend DL::Importer
    dlload "MSVCRT.DLL"
    extern "int _kbhit()"
    extern "int _getch()"
end

class C24com

  def initialize
    @comp1 = Serial.new
  end

  def open
    @comp1.comno = 1
    @comp1.bRate = CBR_115200
    @comp1.byteSize = 8
    @comp1.parity = NOPARITY
    @comp1.fOutxCtsFlow = 0
    @comp1.fOutxDsrFlow = 0
        @comp1.fDsrSensitivity = 0
#    @comp1.fDtrControl = DTR_CONTROL_DISABLE
    ir = @comp1.open
    if ir == nil
       ir = @comp1.escapeCommFunc(SETDTR)
    end
    return ir
  end

  def rclose
     @comp1.close
  end

  def receive
    sr = @comp1.receive
    if sr != nil
       sr.each_byte{ |c|
         ic = c.to_i
       }
    end
  end

  def send(schar)
        @comp1.send(schar)
  end

end

c24com1 = C24com.new
ic = c24com1.open
if ic != nil
  print "openエラー " + ic.to_s
end

loop do
        rx_data = c24com1.receive
        unless rx_data.nil?
                print rx_data
                if rx_data == "\r"
                        print "\n"
                end
        end

        if MSVCRT._kbhit != 0
                ch = MSVCRT._getch
            c24com1.send(ch.chr)
        end
  sleep 0.01
end

sp.close

C:\rubyapi\ci-v>ruby wincom_s2_20120622.rb
01234567890
abcdefghijklmnopqrstuvwxyz

2012年6月22日金曜日

ruby(i386-mingw32) + serialport gem RS-232Cターミナル


RS-232C 9pin D-SUBのSD-RDをLOOPしてテストしてみた。


C:\rubyapi\ci-v>ruby -v
ruby 1.9.3p194 (2012-04-20) [i386-mingw32]

C:\rubyapi\ci-v>gem list

*** LOCAL GEMS ***

archive-tar-minitar (0.5.2)
bigdecimal (1.1.0)
io-console (0.3)
json (1.7.3)
linecache19 (0.5.13)
minitest (3.1.0)
rake (0.9.2.2)
rdoc (3.12)
ruby_core_source (0.1.5)
rubygems-update (1.8.24)
serialport (1.1.0)

C:\rubyapi\ci-v>type civ_com53_20120622.rb
# -*- encoding: Shift_JIS -*-
require 'serialport'
require 'dl/import'
require "thread"

module MSVCRT           #ruby-list:42280 kara
    extend DL::Importer
    dlload "MSVCRT.DLL"
    extern "int _kbhit()"
    extern "int _getch()"
end

sp = SerialPort.new("COM1",115200)
sp.flow_control=0   # NONE:0 HARD:1 SOFT:2
sp.read_timeout=10
sp.write_timeout=0

p sp.get_modem_params
p sp.get_signals
p sp.flow_control
p sp.read_timeout
p sp.write_timeout

tx_data = Queue.new
  tx = Thread.new{
        loop do
      if tx_data.empty? then
                Thread.stop
          else
            sp.write(tx_data.pop)
      end
        end
        }

loop do
        rx_data = sp.read
        unless rx_data.empty?
                print rx_data
                if rx_data == "\r"
                        print "\n"
                end
        end

        if MSVCRT._kbhit != 0
                ch = MSVCRT._getch
                tx_data.push(ch.chr)
                tx.run
        end
  sleep 0.01
end

sp.close

C:\rubyapi\ci-v>ruby civ_com53_20120622.rb
{"baud"=>115200, "data_bits"=>8, "stop_bits"=>1, "parity"=>0}
{"cts"=>0, "dsr"=>0, "dcd"=>0, "ri"=>0}
0
10
0
01234567890
abcdefghijklmnopqrstuvwxyz







2012年6月19日火曜日

UbuntuStudio 12.04 pulseaudio 24bit/96kHzの再生


参考にしたところは、
zenlabo report Ubuntu24bit/96kHzのファイルを再生
音源は

PulseAudioの初期設定の確認
$ pulseaudio --dump-conf
### 設定ファイルから読み込み: /etc/pulse/daemon.conf ###
daemonize = no
fail = yes
high-priority = yes
nice-level = -11
realtime-scheduling = yes
realtime-priority = 5
allow-module-loading = yes
allow-exit = yes
use-pid-file = yes
system-instance = no
local-server-type = user
cpu-limit = no
enable-shm = yes
flat-volumes = no
lock-memory = no
exit-idle-time = 20
scache-idle-time = 20
dl-search-path = /usr/lib/pulse-1.1/modules
default-script-file = /etc/pulse/default.pa
load-default-script-file = yes
log-target = auto
log-level = notice
resample-method = speex-float-1
enable-remixing = yes
enable-lfe-remixing = no
default-sample-format = s16le
default-sample-rate = 44100
default-sample-channels = 2
default-channel-map = front-left,front-right
default-fragments = 8
default-fragment-size-msec = 10
enable-deferred-volume = yes
deferred-volume-safety-margin-usec = 1
deferred-volume-extra-delay-usec = 0
shm-size-bytes = 0
log-meta = no
log-time = no
log-backtrace = 0
rlimit-fsize = -1
rlimit-data = -1
rlimit-stack = -1
rlimit-core = -1
rlimit-rss = -1
rlimit-as = -1
rlimit-nproc = -1
rlimit-nofile = 256
rlimit-memlock = -1
rlimit-locks = -1
rlimit-sigpending = -1
rlimit-msgqueue = -1
rlimit-nice = 31
rlimit-rtprio = 9
rlimit-rttime = 1000000

Visual Analyser 2011


















設定ファイルを書き換えをします。
sudo gedit /etc/pulse/daemon.conf
  以下の2行を修正します。
; default-sample-format = s16le
; default-sample-rate = 44100
 ↓修正
default-sample-format = s24le
default-sample-rate = 96000
PulseAudioの再起動をします。
$ pulseaudio --kill && pulseaudio --start

Visual Analyser 2011













2012年6月16日土曜日

UbuntuStudio 12.04 + Cinnamon 1.4 disktop

sudo add-apt-repository ppa:gwendal-lebihan-dev/cinnamon-stable
sudo apt-get update
sudo apt-get install cinnamon


再起動>ログアウト>ログイン画面でcinnamon セッションを選択してパスワードを入力してログイン

cinnamonでは、ログアウトが無いので自動ログインのままだとセッションを変更できない?

system tools>システム設定>
ユーザーアカウント
ログインオプション>自動ログインをオフにする。

自動ログインをオンにするのは、セッションをgnome classicでloginして、システム設定>

ユーザーアカウントで自動ログインをオンにした。
cinnamon でログアウトを追加、出来ればいいのだが?

UbuntuStudio 12.04 + lubuntu-disktop


UbuntuTips/Desktop/HowToIntroduceLxde を参考に

Ubuntuソフトウェアセンターでlubutu 検索する。

左下の〇〇のアイテムを表示する。
Lubuntu Desktop environment を選択して、インストール

再起動>ログアウト>ログイン画面でLubuntu セッションを選択してパスワードを入力してログイン

ppaの登録
sudo add-apt-repository ppa:lubuntu-desktop/ppa
sudo apt-get update

2012年6月12日火曜日

UbuntuStudio12.04 + WineHQ + Visual Analyser2011

UbuntuStudio12.04
 CPU:Intel Core 2 6420@2.13GHz
 MB:G41M-GS3
 MEM:3864MB
 SSD:32GB
 Audio Adapter:Creative Labs SB X-F1
 Linux 3.2.0-23-realtime(i686)







Visual Analyser 2011で、SuonoDolceのスペクトラムを表示してみた。
PusleAudio 音量調整[録音]でMonitor of  SB X-Fi アナログステレオを選択で出力装置をモニターできる。
システム負荷
  Vislal Analyser 2011 なしで20%前後
           ありで40%弱