Beispiel #1
0
func soundfile() *os.File {
	//
	dev := env.Par(1)
	if dev == "" {
		dev = "cdrom"
	}
	var e error
	cdfile, e = os.OpenFile("/dev/"+dev, syscall.O_RDONLY|syscall.O_NONBLOCK, 0440)
	if e != nil {
		return nil
	}
	cdd = int(cdfile.Fd())
	C.closeTray(C.int(cdd))
	counter := 0
	for { // anfangs dauert's manchmal 'ne Weile ...
		counter++
		if counter > 30 {
			return nil
		}
		_, status = cstatus(cdd)
		if status == invalid {
			ker.Msleep(250 * 1000)
		} else {
			break
		}
	}
	nTracks = uint8(C.nTracks(C.int(cdd)))
	n1 := nTracks + 1
	startFrame = make([]uint, n1)
	StartTime = make([]*clk.Imp, nTracks)
	Length = make([]*clk.Imp, nTracks)
	for t := uint8(0); t <= nTracks; t++ {
		startFrame[t] = uint(C.startFrame(C.int(cdd), C.uchar(t)))
		if t < nTracks {
			StartTime[t] = clk.New()
			Length[t] = clk.New()
			m, s := ms(startFrame[t] - offset)
			StartTime[t].Set(m/60, m%60, s)
		}
		if t > 0 {
			m, s := ms(startFrame[t] - startFrame[t-1] - offset)
			Length[t-1].Set(m/60, m%60, s)
		}
	}
	m, s := ms(startFrame[nTracks] - 2*offset)
	TotalTime.Set(m/60, m%60, s)
	var l, r C.uchar
	C.volRead(C.int(cdd), &l, &r)
	volume_left, volume_right = uint8(l), uint8(r)
	//  C.lockDoor (C.int(cdd))
	Ctrl(All, MaxVol/3)
	return cdfile
}
Beispiel #2
0
func New(o Object) *Imp {
	//
	x := new(Imp)
	switch o.(type) {
	case *enum.Imp:
		x.Object, x.typ = enum.New(enum.Enum(o.(*enum.Imp).Typ())), Enumerator
	case *tval.Imp:
		x.Object, x.typ = tval.New(), TruthValue
	case *char.Imp:
		x.Object, x.typ = char.New(), Character
	case *text.Imp:
		x.Object, x.typ = text.New(o.(*text.Imp).Len()), Text
	case *bnat.Imp:
		x.Object, x.typ = bnat.New(o.(*bnat.Imp).Startval()), Natural
	case *breal.Imp:
		x.Object, x.typ = breal.New(4), Real
	case *clk.Imp:
		x.Object, x.typ = clk.New(), Clocktime
	case *day.Imp:
		x.Object, x.typ = day.New(), Calendarday
	case *euro.Imp:
		x.Object, x.typ = euro.New(), Euro
	case *cntry.Imp:
		x.Object, x.typ = cntry.New(), Country
	case *pers.Imp:
		x.Object, x.typ = pers.New(), Person
	case *phone.Imp:
		x.Object, x.typ = phone.New(), PhoneNumber
	case *addr.Imp:
		x.Object, x.typ = addr.New(), Address
	default:
		ker.Panic("atom.New: parameter does not characterize an atom.Atomtype")
	}
	return x
}
Beispiel #3
0
func New() *Imp {
	//
	x := new(Imp)
	x.c = clk.New()
	x.a = attr.New()
	x.w = word.New()
	x.t = text.New(54) // 80 - 5 - 5 - 12 - 4 (NCols - clk - attr - word - spaces)
	x.t.SetColours(ctF, ctB)
	return x
}
Beispiel #4
0
func Selected(l, c uint) *Imp {
	//
	cF, cH := col.ScreenF, col.ScreenB
	col.Contrast(&cH)
	n := uint(0)
	z, s := scr.MousePos()
	x := new(Imp)
	sel.Select1(name, uint(NAtomtypes), M, &n, z, s, cF, cH)
	if n < uint(NAtomtypes) {
		x.typ = Atomtype(n)
	} else {
		return nil
	}
	switch x.typ {
	case Enumerator:
		e := enum.Title // TODO e per select-menue aussuchen
		x.Object = enum.New(e)
	case TruthValue:
		x.Object = tval.New()
	case Character:
		x.Object = char.New()
	case Text:
		n := uint(10) // TODO n editieren
		x.Object = text.New(n)
	case Natural:
		n := uint(10) // TODO n editieren
		x.Object = bnat.New(n)
	case Real:
		n := uint(6) // TODO n editieren
		x.Object = breal.New(n)
	case Clocktime:
		x.Object = clk.New()
	case Calendarday:
		x.Object = day.New()
	case Euro:
		x.Object = euro.New()
	case Country:
		x.Object = cntry.New()
	case Person:
		x.Object = pers.New()
	case PhoneNumber:
		x.Object = phone.New()
	case Address:
		x.Object = addr.New()
	}
	return New(x)
}
Beispiel #5
0
const MaxVol = 1<<8 - 1

type Controller uint8

const (
	Left = iota
	Right
	Balance
	All
	NCtrl
)

var (
	StartTime, Length          []*clk.Imp
	TotalTime, Time, TrackTime *clk.Imp = clk.New(), clk.New(), clk.New()
	Ctrltext                   [NCtrl]string
)

// Returns the open file /dev/cdrom, iff there is a readable
// audio CD or DVD in that device ("cdrom" can be replaced by the
// 1st parameter in the call of the program, that uses this package).
// In this case TotalTime and the StartTime and Length of all
// entries of the CD/DVD are defined. Returns otherwise nil.
// The execution of this function with result != nil
// is the precondition for all further functions.
func Soundfile() *os.File { return soundfile() }

// Returns the number of tracks of the CD.
func NTracks() uint8 { return nTracks }
Beispiel #6
0
func New() *Imp {
	//
	return &Imp{day.New(), clk.New()}
}
Beispiel #7
0
	"murus/day"
	"murus/font"
	. "murus/obj"
	"murus/prt"
	"murus/scr"
	"murus/str"
)

type Imp struct {
	day  *day.Imp
	time *clk.Imp
}

const separator = ','

var one, two, three, lastTime *clk.Imp = clk.New(), clk.New(), clk.New(), clk.New()

func (x *Imp) imp(Y Object) *Imp {
	//
	y, ok := Y.(*Imp)
	if !ok {
		TypeNotEqPanic(x, Y)
	}
	return y
}

func New() *Imp {
	//
	return &Imp{day.New(), clk.New()}
}