2017년 10월 4일 수요일

맥북에서 콘솔프로그램 실행해보기...

맥북에서 라자루스를 이용하여 콘솔용 프로그램을 만들어 실행해보았는데,
윈도우와는 약간 환경이 다른 것 같네요.
결과를 확인 할 수 없습니다.
아래와 같은 프로그램을 만들어 실행하면 화면만 깜박하고 넘어가버리네요...

program Project2;
{$mode objfpc}{$H+}
uses
  Classes;
begin
  writeln('Hello World!');
  writeln('안녕하세요');
  ReadLn;
end.

결국!
finder 에서 해당 파일을 선택하고 열기를 하니 터미널이 열리고 실행 결과를 확인할 수 있네요.
잠시 멈추는 기능은 구현하기 힘드는 걸까?

아직! 다른 방법을 확인해보지 못했습니다.<2017.10.4>

2017년 10월 3일 화요일

공개된 소스 활용하여 Swift 에서 프로그램하기 (podfile)

리치에디터라는 소스공개 프로그램을 내 컴에서 실행해 보려고 하면 github 에서 해당 프로젝트를 받아온다음 pod를 생성하고 cocoapods을 이용하여 자동 버전관리를 할 수 있습니다.(예시임).

터미널에서
$ sudo gem install cocoapods
$ pod setup
하여 코코아팟을 설치합니다.

다운 받은 폴더로 이동하여
터미널에서 pod install 합니다.

swift를 실행하고 프로젝트 열기를 하지 말고 워크스페이스 열기합니다.

새로 프로젝트를 만들경우에는 생성된 프로젝트와 동일한 폴더에
워크스페이스를 만들고
podfile 파일을 생성한 다음
터미널에서 해당 폴더로 이동한 다음 pop install 합니다.
프로젝트의 '/' 위치에 있는 podfile 파일 샘플입니다.


use_frameworks!

target 'RichEditorViewSample' do
    pod "RichEditorView", :path => "../"

end

만약 github에서 가져오려면 path 를 https:// 하여 지정하면 되겠지요.
즐거운 프로그램 되세요.



2017년 6월 4일 일요일

안드로이드 개발자 옵션 보이게하기

On most Android devices,  the Developer options menu is hidden by default.

To unhide the Developer options menu:

1.  Tap Apps Apps Icon 
2.  Tap Settings Icon Settings 
3. Tap  About device Settings About Icon 

4. Scroll to and touch Build number seven times
5. Go back to Settings, the Developer options menu will now appear under Settings Icon Settings > General > Developer options Settings Developer Icon .

2017년 5월 23일 화요일

No bootable device Insert boot disk and press any key.

맥북(macbook)에 부트캠프(bootcamp)를 사용하여 윈도우 10을 설치하였는데,
어느날 갑자기, osx로 부팅하고 다시 windows로 부팅하려고 하였더니.
No bootable device Insert boot disk and press any key.
라는 에러가 나오며 윈도우10이 부팅이 안된다.
물론 컴퓨터 전원을 켬과 동시에 option(alt) key를 눌러 osx 와 windows를 선택 할 수는 있는데 매번 그러기에는 번잡하였다.
무었이 원인 일 까 조사했더니 윈도우 설치과정에서 파티션이 한개 더 잡혀버렸다(100M).
그래서 부팅시 먼저 선택해 버린다.
혹시나 하고 easybcd.exe 를 다운 받아 설치하고 ( http://neosmart.net/EasyBCD/ )
임의의 부팅을 만든다음 멀티부팅으로 시작하도록 하였더니
전원 켬과 동시에 멀티부팅 화면이 나타난다.
다시 easybcd를 실행하여 추가한 멀티부팅 메뉴를 삭제하고 시간지연을 없앴더니
곧바로 부팅이 된다.
몇일간 고민했었는데 해결이 되었다.
추가! osx 로 다시 갔다가 오니 또 안되네요.
아무래도 efi... 관련인 것 같은데 해결을 못했네요.
추가(2017.5.23)! OSX를 최신버전으로 업그레이드 했더니 해결되었습니다.
참고로 efi 관련자료는 http://m.blog.naver.com/sun2ace/220297691509 참고.


2017년 2월 5일 일요일

MS의 SpVoice를 임포트하여 글 읽어 주기를 구현했네요.

목소리가 별로 네요... 예전에 구글 API 이용 했었는데 그걸로 돌아 갈까....
음성을 선택 할 수 있는데 별반 차이가 없네요.

procedure TfrmStudyLaw2.FormCreate(Sender: TObject);
var
FileName: String;
SOTokenVoice: ISpeechObjectToken;
SOTokenVoices: ISpeechObjectTokens;
....
begin
// speech
SpVoice1.EventInterests:= SVEAllEvents;
SOTokenVoices:= SpVoice1.GetVoices('','');
for i := 0 to SOTokenVoices.Count-1 do begin
SOTokenVoice:= SOTokenVoices.Item(i);
ComboBoxVoices.Items.AddObject(SOTokenVoice.GetDescription(0), TObject(SOTokenVoice));
SOTokenVoice._AddRef;
end;
if ComboBoxVoices.Items.Count > 0 then begin
ComboBoxVoices.ItemIndex := ComboBoxVoices.Items.IndexOf(SpVoice1.Voice.GetDescription(0))
end;
end.


procedure TfrmStudyLaw2.Button5Click(Sender: TObject);
const iSpeechFlags: integer = SVSFlagsAsync + SVSFPurgeBeforeSpeak + SVSFIsXML;
var
idx, jdx, kdx: Integer;
begin
SpVoice1.Rate:= tbRate.Position;
for idx := 0 to SpinEdit1.Value-1 do begin
if CBStopSpeechA.Checked then Break;
for jdx := 0 to ListBox1.Items.Count-1 do begin
if CBStopSpeechA.Checked then Break;
if ListBox1.Checked[jdx] then
for kdx := 0 to SpinEdit2.Value-1 do begin
if CBStopSpeech1.Checked then Break;
SpVoice1.Speak(ListBox1.Items[jdx],iSpeechFlags);
repeat
Application.ProcessMessages;
until (SpVoice1.WaitUntilDone(10));
end;
CBStopSpeech1.Checked:= False;
end;
end;
CBStopSpeechA.Checked:= False;
end;

트랙바를 이용하여 mp3 구간 옮기기 트랙바에 MouseDown 이벤트 없어서

트랙바를 이용하여 mp3 구간 옮기기 트랙바에 MouseDown 이벤트 없어서

TTrackBar = class(Vcl.ComCtrls.TTrackbar)
  protected
    property OnMouseUp;
    property OnMouseDown;
  end;
  .....
    procedure CheckListBox1ClickCheck(Sender: TObject);
    procedure CheckListBox1Click(Sender: TObject);


procedure TForm1.TBMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
Timer1.Enabled:= False;
BASS_ChannelPause(iStream);
end;

procedure TForm1.TBMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
BASS_ChannelSetPosition(iStream, TrackBar2.Position,0);
BASS_ChannelPlay(iStream,False);
Timer1.Enabled:= True;
end;

procedure TForm1.TrackBar1Change(Sender: TObject);
begin
StatusBar1.SimpleText:= '지연시간(100mSec) : '+ IntToStr(TrackBar1.Position);
end;

Bass.dll 을 이용한 mp3 연속 플레이하기

폼생성시 초기화 합니다.
mp3 파일은 sqlite 파일로 되어 있어 CheckListBox로 필요한 것만 읽어 옮니다.
트랙바 부분은 아래에 설명

procedure TForm1.FormCreate(Sender: TObject);
var istr: string;
begin
TrackBar2.OnMouseUp := TBMouseUp;
TrackBar2.OnMouseDown := TBMouseDown;
ZConnection1.Connect;
ZTable1.Open;
// check the correct BASS was loaded
if (HIWORD(BASS_GetVersion) <> BASSVERSION) then begin
MessageBox(0,'An incorrect version',nil,MB_ICONERROR);
Halt;
end;
iPause:= False;
// Initialize audio - default device, 44100hz, stereo, 16 bits
if not BASS_Init(-1, 44100, 0, Handle, nil) then
Error('Error initializing audio!');
end;

시작버튼

procedure TForm1.btPlayClick(Sender: TObject);
var
iCoor: TPoint;
begin
Timer1.Enabled:= False;
iPause:= False;
btRestart.Caption:= 'Pause';
BASS_ChannelStop(iStream);
if CheckListBox1.items.Count = 0 then exit;
// Play the stream (continuing from current position)
if CheckListBox1.ItemIndex >= 0 then begin
iCount:= 0;
playmp3(CheckListBox1.ItemIndex);
TrackBar2.Max:= BASS_ChannelGetLength(iStream, BASS_POS_BYTE);
Timer1.Enabled:= True;
end;
btDate.Caption:= DBEdit2.Text;
end;

Bass Stream 을 생성(파일 경로로); istream: integer로 전역 선언

procedure TForm1.playmp3(idx: integer);
var f: PChar;
begin
if CheckListBox1.checked[idx]= True then exit;

f:= PChar(CheckListBox1.items[idx]);
iStream:= BASS_StreamCreateFile(False, f, 0, 0, 0 or BASS_UNICODE);
//BASS_ChannelSetAttribute(iStream, BASS_ATTRIB_PAN, (Random(201) - 100) / 100);
//BASS_ChannelSetAttribute(iStream, BASS_ATTRIB_VOL, 0.8);
if not BASS_ChannelPlay(iStream, True) then Error('Error playing stream!');
end;

타이머가 돌아가면서 하나의 mp3 가 끝났는지 확인하고 반복하고나 다음 mp3 연주

procedure TForm1.Timer1Timer(Sender: TObject);
begin
if BASS_GetCPU < 0.00001 then begin
inc(iCount);
if iCount >= spinedit1.Value then begin
iCount:= 0;
CheckListBox1.ItemIndex:= CheckListBox1.ItemIndex + 1;
CheckListBox1.Tag:= CheckListBox1.Tag + 1;
ZQuery1.Next;
if CheckListBox1.Tag <> CheckListBox1.ItemIndex then begin
CheckListBox1.ItemIndex:= 0;
CheckListBox1.Tag:= 0;
iCount:= 0;
Zquery1.First;
Timer1.Enabled:= False;
end else
//
end;
Timer1.Enabled:= False;
if CheckListBox1.Checked[CheckListBox1.ItemIndex]= False then
Delay(TrackBar1.Position*100);
playmp3(CheckListBox1.ItemIndex);
TrackBar2.Max:= BASS_ChannelGetLength(iStream, BASS_POS_BYTE);
Timer1.Enabled:= True;
end;
TrackBar2.Position := BASS_ChannelGetPosition(iStream, BASS_POS_BYTE);
end;

prophet 를 이용하여 시계열 예측을 할때 설치가 안될때(fbprophet)

 pip install fbprophet 으로 설치가 안될때 python -m pip install prophet 으로 설치하고. fbprophet을 prophet으로 바꾸어 준다. from prophet import Prophet from p...