id int32 0 167k | repo stringlengths 5 54 | path stringlengths 4 155 | func_name stringlengths 1 118 | original_string stringlengths 52 85.5k | language stringclasses 1
value | code stringlengths 52 85.5k | code_tokens list | docstring stringlengths 6 2.61k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 85 252 |
|---|---|---|---|---|---|---|---|---|---|---|---|
148,700 | curator-go/curator | recipes/cache/tree_cache.go | SetLogger | func (tc *TreeCache) SetLogger(l Logger) *TreeCache {
tc.logger = l
return tc
} | go | func (tc *TreeCache) SetLogger(l Logger) *TreeCache {
tc.logger = l
return tc
} | [
"func",
"(",
"tc",
"*",
"TreeCache",
")",
"SetLogger",
"(",
"l",
"Logger",
")",
"*",
"TreeCache",
"{",
"tc",
".",
"logger",
"=",
"l",
"\n",
"return",
"tc",
"\n",
"}"
] | // SetLogger sets the inner Logger of TreeCache. | [
"SetLogger",
"sets",
"the",
"inner",
"Logger",
"of",
"TreeCache",
"."
] | 8a961ea3b25229b9b328724b8b2059ab58c1d16b | https://github.com/curator-go/curator/blob/8a961ea3b25229b9b328724b8b2059ab58c1d16b/recipes/cache/tree_cache.go#L154-L157 |
148,701 | curator-go/curator | recipes/cache/tree_cache.go | Stop | func (tc *TreeCache) Stop() {
if tc.state.Change(curator.STARTED, curator.STOPPED) {
tc.client.ConnectionStateListenable().RemoveListener(tc.connectionStateListener)
tc.listeners.Clear()
tc.root.wasDeleted()
}
} | go | func (tc *TreeCache) Stop() {
if tc.state.Change(curator.STARTED, curator.STOPPED) {
tc.client.ConnectionStateListenable().RemoveListener(tc.connectionStateListener)
tc.listeners.Clear()
tc.root.wasDeleted()
}
} | [
"func",
"(",
"tc",
"*",
"TreeCache",
")",
"Stop",
"(",
")",
"{",
"if",
"tc",
".",
"state",
".",
"Change",
"(",
"curator",
".",
"STARTED",
",",
"curator",
".",
"STOPPED",
")",
"{",
"tc",
".",
"client",
".",
"ConnectionStateListenable",
"(",
")",
".",
... | // Stop stops the cache. | [
"Stop",
"stops",
"the",
"cache",
"."
] | 8a961ea3b25229b9b328724b8b2059ab58c1d16b | https://github.com/curator-go/curator/blob/8a961ea3b25229b9b328724b8b2059ab58c1d16b/recipes/cache/tree_cache.go#L160-L166 |
148,702 | curator-go/curator | recipes/cache/tree_cache.go | findNode | func (tc *TreeCache) findNode(path string) (*TreeNode, error) {
if !strings.HasPrefix(path, tc.root.path) {
return nil, ErrRootNotMatch
}
path = strings.TrimPrefix(path, tc.root.path)
current := tc.root
for _, part := range strings.Split(path, "/") {
if part == "" {
continue
}
next, exists := current.F... | go | func (tc *TreeCache) findNode(path string) (*TreeNode, error) {
if !strings.HasPrefix(path, tc.root.path) {
return nil, ErrRootNotMatch
}
path = strings.TrimPrefix(path, tc.root.path)
current := tc.root
for _, part := range strings.Split(path, "/") {
if part == "" {
continue
}
next, exists := current.F... | [
"func",
"(",
"tc",
"*",
"TreeCache",
")",
"findNode",
"(",
"path",
"string",
")",
"(",
"*",
"TreeNode",
",",
"error",
")",
"{",
"if",
"!",
"strings",
".",
"HasPrefix",
"(",
"path",
",",
"tc",
".",
"root",
".",
"path",
")",
"{",
"return",
"nil",
"... | // findNode finds the node which matches the given path.
// ErrRootNotMatch is returned if the given path doesn't share a same root with
// the TreeCache.
// ErrNodeNotFound is returned if the given path can not be found. | [
"findNode",
"finds",
"the",
"node",
"which",
"matches",
"the",
"given",
"path",
".",
"ErrRootNotMatch",
"is",
"returned",
"if",
"the",
"given",
"path",
"doesn",
"t",
"share",
"a",
"same",
"root",
"with",
"the",
"TreeCache",
".",
"ErrNodeNotFound",
"is",
"ret... | 8a961ea3b25229b9b328724b8b2059ab58c1d16b | https://github.com/curator-go/curator/blob/8a961ea3b25229b9b328724b8b2059ab58c1d16b/recipes/cache/tree_cache.go#L191-L210 |
148,703 | curator-go/curator | recipes/cache/tree_cache.go | CurrentChildren | func (tc *TreeCache) CurrentChildren(fullPath string) (map[string]*ChildData, error) {
node, err := tc.findNode(fullPath)
if err != nil {
return nil, err
}
if node.state.Load() != NodeStateLIVE {
return nil, ErrNodeNotLive
}
children := node.Children()
m := make(map[string]*ChildData, len(children))
for ch... | go | func (tc *TreeCache) CurrentChildren(fullPath string) (map[string]*ChildData, error) {
node, err := tc.findNode(fullPath)
if err != nil {
return nil, err
}
if node.state.Load() != NodeStateLIVE {
return nil, ErrNodeNotLive
}
children := node.Children()
m := make(map[string]*ChildData, len(children))
for ch... | [
"func",
"(",
"tc",
"*",
"TreeCache",
")",
"CurrentChildren",
"(",
"fullPath",
"string",
")",
"(",
"map",
"[",
"string",
"]",
"*",
"ChildData",
",",
"error",
")",
"{",
"node",
",",
"err",
":=",
"tc",
".",
"findNode",
"(",
"fullPath",
")",
"\n",
"if",
... | // CurrentChildren returns the current set of children at the given full path, mapped by child name.
// There are no guarantees of accuracy; this is merely the most recent view of the data.
// If there is no node at this path, ErrNodeNotFound is returned. | [
"CurrentChildren",
"returns",
"the",
"current",
"set",
"of",
"children",
"at",
"the",
"given",
"full",
"path",
"mapped",
"by",
"child",
"name",
".",
"There",
"are",
"no",
"guarantees",
"of",
"accuracy",
";",
"this",
"is",
"merely",
"the",
"most",
"recent",
... | 8a961ea3b25229b9b328724b8b2059ab58c1d16b | https://github.com/curator-go/curator/blob/8a961ea3b25229b9b328724b8b2059ab58c1d16b/recipes/cache/tree_cache.go#L215-L239 |
148,704 | curator-go/curator | recipes/cache/tree_cache.go | CurrentData | func (tc *TreeCache) CurrentData(fullPath string) (*ChildData, error) {
node, err := tc.findNode(fullPath)
if err != nil {
return nil, err
}
if node.state.Load() != NodeStateLIVE {
return nil, ErrNodeNotLive
}
return node.ChildData(), nil
} | go | func (tc *TreeCache) CurrentData(fullPath string) (*ChildData, error) {
node, err := tc.findNode(fullPath)
if err != nil {
return nil, err
}
if node.state.Load() != NodeStateLIVE {
return nil, ErrNodeNotLive
}
return node.ChildData(), nil
} | [
"func",
"(",
"tc",
"*",
"TreeCache",
")",
"CurrentData",
"(",
"fullPath",
"string",
")",
"(",
"*",
"ChildData",
",",
"error",
")",
"{",
"node",
",",
"err",
":=",
"tc",
".",
"findNode",
"(",
"fullPath",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"ret... | // CurrentData returns the current data for the given full path.
// There are no guarantees of accuracy. This is merely the most recent view of the data.
// If there is no node at the given path, ErrNodeNotFound is returned. | [
"CurrentData",
"returns",
"the",
"current",
"data",
"for",
"the",
"given",
"full",
"path",
".",
"There",
"are",
"no",
"guarantees",
"of",
"accuracy",
".",
"This",
"is",
"merely",
"the",
"most",
"recent",
"view",
"of",
"the",
"data",
".",
"If",
"there",
"... | 8a961ea3b25229b9b328724b8b2059ab58c1d16b | https://github.com/curator-go/curator/blob/8a961ea3b25229b9b328724b8b2059ab58c1d16b/recipes/cache/tree_cache.go#L244-L254 |
148,705 | curator-go/curator | recipes/cache/tree_cache.go | handleException | func (tc *TreeCache) handleException(e error) {
if tc.errorListeners.Len() == 0 {
tc.logger.Printf("%s", e)
return
}
tc.errorListeners.ForEach(func(listener interface{}) {
listener.(curator.UnhandledErrorListener).UnhandledError(e)
})
} | go | func (tc *TreeCache) handleException(e error) {
if tc.errorListeners.Len() == 0 {
tc.logger.Printf("%s", e)
return
}
tc.errorListeners.ForEach(func(listener interface{}) {
listener.(curator.UnhandledErrorListener).UnhandledError(e)
})
} | [
"func",
"(",
"tc",
"*",
"TreeCache",
")",
"handleException",
"(",
"e",
"error",
")",
"{",
"if",
"tc",
".",
"errorListeners",
".",
"Len",
"(",
")",
"==",
"0",
"{",
"tc",
".",
"logger",
".",
"Printf",
"(",
"\"",
"\"",
",",
"e",
")",
"\n",
"return",... | // handleException sends an exception to any listeners, or else log the error if there are none. | [
"handleException",
"sends",
"an",
"exception",
"to",
"any",
"listeners",
"or",
"else",
"log",
"the",
"error",
"if",
"there",
"are",
"none",
"."
] | 8a961ea3b25229b9b328724b8b2059ab58c1d16b | https://github.com/curator-go/curator/blob/8a961ea3b25229b9b328724b8b2059ab58c1d16b/recipes/cache/tree_cache.go#L267-L275 |
148,706 | curator-go/curator | recipes/cache/tree_cache.go | publishEvent | func (tc *TreeCache) publishEvent(tp TreeCacheEventType, data *ChildData) {
if tc.state.Value() != curator.STOPPED {
evt := TreeCacheEvent{Type: tp, Data: data}
tc.logger.Debugf("publishEvent: %v", evt)
go tc.callListeners(evt)
}
} | go | func (tc *TreeCache) publishEvent(tp TreeCacheEventType, data *ChildData) {
if tc.state.Value() != curator.STOPPED {
evt := TreeCacheEvent{Type: tp, Data: data}
tc.logger.Debugf("publishEvent: %v", evt)
go tc.callListeners(evt)
}
} | [
"func",
"(",
"tc",
"*",
"TreeCache",
")",
"publishEvent",
"(",
"tp",
"TreeCacheEventType",
",",
"data",
"*",
"ChildData",
")",
"{",
"if",
"tc",
".",
"state",
".",
"Value",
"(",
")",
"!=",
"curator",
".",
"STOPPED",
"{",
"evt",
":=",
"TreeCacheEvent",
"... | // publishEvent publish an event with given type and data to all listeners. | [
"publishEvent",
"publish",
"an",
"event",
"with",
"given",
"type",
"and",
"data",
"to",
"all",
"listeners",
"."
] | 8a961ea3b25229b9b328724b8b2059ab58c1d16b | https://github.com/curator-go/curator/blob/8a961ea3b25229b9b328724b8b2059ab58c1d16b/recipes/cache/tree_cache.go#L294-L300 |
148,707 | curator-go/curator | framework.go | NewClient | func NewClient(connString string, retryPolicy RetryPolicy) CuratorFramework {
return NewClientTimeout(connString, DEFAULT_SESSION_TIMEOUT, DEFAULT_CONNECTION_TIMEOUT, retryPolicy)
} | go | func NewClient(connString string, retryPolicy RetryPolicy) CuratorFramework {
return NewClientTimeout(connString, DEFAULT_SESSION_TIMEOUT, DEFAULT_CONNECTION_TIMEOUT, retryPolicy)
} | [
"func",
"NewClient",
"(",
"connString",
"string",
",",
"retryPolicy",
"RetryPolicy",
")",
"CuratorFramework",
"{",
"return",
"NewClientTimeout",
"(",
"connString",
",",
"DEFAULT_SESSION_TIMEOUT",
",",
"DEFAULT_CONNECTION_TIMEOUT",
",",
"retryPolicy",
")",
"\n",
"}"
] | // Create a new client with default session timeout and default connection timeout | [
"Create",
"a",
"new",
"client",
"with",
"default",
"session",
"timeout",
"and",
"default",
"connection",
"timeout"
] | 8a961ea3b25229b9b328724b8b2059ab58c1d16b | https://github.com/curator-go/curator/blob/8a961ea3b25229b9b328724b8b2059ab58c1d16b/framework.go#L98-L100 |
148,708 | curator-go/curator | framework.go | NewClientTimeout | func NewClientTimeout(connString string, sessionTimeout, connectionTimeout time.Duration, retryPolicy RetryPolicy) CuratorFramework {
builder := &CuratorFrameworkBuilder{
ConnectionTimeout: connectionTimeout,
SessionTimeout: sessionTimeout,
RetryPolicy: retryPolicy,
}
return builder.ConnectString(con... | go | func NewClientTimeout(connString string, sessionTimeout, connectionTimeout time.Duration, retryPolicy RetryPolicy) CuratorFramework {
builder := &CuratorFrameworkBuilder{
ConnectionTimeout: connectionTimeout,
SessionTimeout: sessionTimeout,
RetryPolicy: retryPolicy,
}
return builder.ConnectString(con... | [
"func",
"NewClientTimeout",
"(",
"connString",
"string",
",",
"sessionTimeout",
",",
"connectionTimeout",
"time",
".",
"Duration",
",",
"retryPolicy",
"RetryPolicy",
")",
"CuratorFramework",
"{",
"builder",
":=",
"&",
"CuratorFrameworkBuilder",
"{",
"ConnectionTimeout",... | // Create a new client | [
"Create",
"a",
"new",
"client"
] | 8a961ea3b25229b9b328724b8b2059ab58c1d16b | https://github.com/curator-go/curator/blob/8a961ea3b25229b9b328724b8b2059ab58c1d16b/framework.go#L103-L111 |
148,709 | curator-go/curator | framework.go | Build | func (b *CuratorFrameworkBuilder) Build() CuratorFramework {
if b.EnsembleProvider == nil {
panic("missed ensemble provider")
}
builder := *b
if builder.SessionTimeout == 0 {
builder.SessionTimeout = DEFAULT_SESSION_TIMEOUT
}
if builder.ConnectionTimeout == 0 {
builder.ConnectionTimeout = DEFAULT_CONNECTI... | go | func (b *CuratorFrameworkBuilder) Build() CuratorFramework {
if b.EnsembleProvider == nil {
panic("missed ensemble provider")
}
builder := *b
if builder.SessionTimeout == 0 {
builder.SessionTimeout = DEFAULT_SESSION_TIMEOUT
}
if builder.ConnectionTimeout == 0 {
builder.ConnectionTimeout = DEFAULT_CONNECTI... | [
"func",
"(",
"b",
"*",
"CuratorFrameworkBuilder",
")",
"Build",
"(",
")",
"CuratorFramework",
"{",
"if",
"b",
".",
"EnsembleProvider",
"==",
"nil",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"builder",
":=",
"*",
"b",
"\n\n",
"if",
"builder... | // Apply the current values and build a new CuratorFramework | [
"Apply",
"the",
"current",
"values",
"and",
"build",
"a",
"new",
"CuratorFramework"
] | 8a961ea3b25229b9b328724b8b2059ab58c1d16b | https://github.com/curator-go/curator/blob/8a961ea3b25229b9b328724b8b2059ab58c1d16b/framework.go#L129-L153 |
148,710 | curator-go/curator | framework.go | ConnectString | func (b *CuratorFrameworkBuilder) ConnectString(connectString string) *CuratorFrameworkBuilder {
b.EnsembleProvider = &FixedEnsembleProvider{connectString}
return b
} | go | func (b *CuratorFrameworkBuilder) ConnectString(connectString string) *CuratorFrameworkBuilder {
b.EnsembleProvider = &FixedEnsembleProvider{connectString}
return b
} | [
"func",
"(",
"b",
"*",
"CuratorFrameworkBuilder",
")",
"ConnectString",
"(",
"connectString",
"string",
")",
"*",
"CuratorFrameworkBuilder",
"{",
"b",
".",
"EnsembleProvider",
"=",
"&",
"FixedEnsembleProvider",
"{",
"connectString",
"}",
"\n\n",
"return",
"b",
"\n... | // Set the list of servers to connect to. | [
"Set",
"the",
"list",
"of",
"servers",
"to",
"connect",
"to",
"."
] | 8a961ea3b25229b9b328724b8b2059ab58c1d16b | https://github.com/curator-go/curator/blob/8a961ea3b25229b9b328724b8b2059ab58c1d16b/framework.go#L156-L160 |
148,711 | curator-go/curator | framework.go | Authorization | func (b *CuratorFrameworkBuilder) Authorization(scheme string, auth []byte) *CuratorFrameworkBuilder {
b.AuthInfos = append(b.AuthInfos, AuthInfo{scheme, auth})
return b
} | go | func (b *CuratorFrameworkBuilder) Authorization(scheme string, auth []byte) *CuratorFrameworkBuilder {
b.AuthInfos = append(b.AuthInfos, AuthInfo{scheme, auth})
return b
} | [
"func",
"(",
"b",
"*",
"CuratorFrameworkBuilder",
")",
"Authorization",
"(",
"scheme",
"string",
",",
"auth",
"[",
"]",
"byte",
")",
"*",
"CuratorFrameworkBuilder",
"{",
"b",
".",
"AuthInfos",
"=",
"append",
"(",
"b",
".",
"AuthInfos",
",",
"AuthInfo",
"{"... | // Add connection authorization | [
"Add",
"connection",
"authorization"
] | 8a961ea3b25229b9b328724b8b2059ab58c1d16b | https://github.com/curator-go/curator/blob/8a961ea3b25229b9b328724b8b2059ab58c1d16b/framework.go#L163-L167 |
148,712 | curator-go/curator | framework.go | Compression | func (b *CuratorFrameworkBuilder) Compression(name string) *CuratorFrameworkBuilder {
if provider, exists := CompressionProviders[name]; exists {
b.CompressionProvider = provider
}
return b
} | go | func (b *CuratorFrameworkBuilder) Compression(name string) *CuratorFrameworkBuilder {
if provider, exists := CompressionProviders[name]; exists {
b.CompressionProvider = provider
}
return b
} | [
"func",
"(",
"b",
"*",
"CuratorFrameworkBuilder",
")",
"Compression",
"(",
"name",
"string",
")",
"*",
"CuratorFrameworkBuilder",
"{",
"if",
"provider",
",",
"exists",
":=",
"CompressionProviders",
"[",
"name",
"]",
";",
"exists",
"{",
"b",
".",
"CompressionPr... | // Add compression provider | [
"Add",
"compression",
"provider"
] | 8a961ea3b25229b9b328724b8b2059ab58c1d16b | https://github.com/curator-go/curator/blob/8a961ea3b25229b9b328724b8b2059ab58c1d16b/framework.go#L170-L176 |
148,713 | curator-go/curator | namespace.go | FixForNamespace | func FixForNamespace(namespace, path string, isSequential bool) (string, error) {
if len(namespace) > 0 {
return JoinPath(namespace, path), nil
}
return path, nil
} | go | func FixForNamespace(namespace, path string, isSequential bool) (string, error) {
if len(namespace) > 0 {
return JoinPath(namespace, path), nil
}
return path, nil
} | [
"func",
"FixForNamespace",
"(",
"namespace",
",",
"path",
"string",
",",
"isSequential",
"bool",
")",
"(",
"string",
",",
"error",
")",
"{",
"if",
"len",
"(",
"namespace",
")",
">",
"0",
"{",
"return",
"JoinPath",
"(",
"namespace",
",",
"path",
")",
",... | // Apply the namespace to the given path | [
"Apply",
"the",
"namespace",
"to",
"the",
"given",
"path"
] | 8a961ea3b25229b9b328724b8b2059ab58c1d16b | https://github.com/curator-go/curator/blob/8a961ea3b25229b9b328724b8b2059ab58c1d16b/namespace.go#L36-L42 |
148,714 | curator-go/curator | examples/zktreeutil/zktree.go | Merge | func (t *ZkLiveTree) Merge(tree *ZkLoadedTree, force bool) error {
if force {
if len(t.client.Namespace()) > 0 {
t.client.Delete().DeletingChildrenIfNeeded().ForPath("/")
} else if children, err := t.client.GetChildren().ForPath("/"); err != nil {
return err
} else {
for _, child := range children {
... | go | func (t *ZkLiveTree) Merge(tree *ZkLoadedTree, force bool) error {
if force {
if len(t.client.Namespace()) > 0 {
t.client.Delete().DeletingChildrenIfNeeded().ForPath("/")
} else if children, err := t.client.GetChildren().ForPath("/"); err != nil {
return err
} else {
for _, child := range children {
... | [
"func",
"(",
"t",
"*",
"ZkLiveTree",
")",
"Merge",
"(",
"tree",
"*",
"ZkLoadedTree",
",",
"force",
"bool",
")",
"error",
"{",
"if",
"force",
"{",
"if",
"len",
"(",
"t",
".",
"client",
".",
"Namespace",
"(",
")",
")",
">",
"0",
"{",
"t",
".",
"c... | // writes the in-memory ZK tree on to ZK server | [
"writes",
"the",
"in",
"-",
"memory",
"ZK",
"tree",
"on",
"to",
"ZK",
"server"
] | 8a961ea3b25229b9b328724b8b2059ab58c1d16b | https://github.com/curator-go/curator/blob/8a961ea3b25229b9b328724b8b2059ab58c1d16b/examples/zktreeutil/zktree.go#L267-L307 |
148,715 | curator-go/curator | examples/zktreeutil/zktree.go | Diff | func (t *ZkLiveTree) Diff(tree *ZkLoadedTree) error {
tree.Root().Visit(func(node *ZkNode, ctxt *ZkNodeContext) bool {
if strings.HasPrefix(node.Path, "/zookeeper") {
return true
}
if err := t.diffNode(node); err != nil {
log.Fatalf("fail to diff node `%s`, %s", node.Path, err)
return false
}
ret... | go | func (t *ZkLiveTree) Diff(tree *ZkLoadedTree) error {
tree.Root().Visit(func(node *ZkNode, ctxt *ZkNodeContext) bool {
if strings.HasPrefix(node.Path, "/zookeeper") {
return true
}
if err := t.diffNode(node); err != nil {
log.Fatalf("fail to diff node `%s`, %s", node.Path, err)
return false
}
ret... | [
"func",
"(",
"t",
"*",
"ZkLiveTree",
")",
"Diff",
"(",
"tree",
"*",
"ZkLoadedTree",
")",
"error",
"{",
"tree",
".",
"Root",
"(",
")",
".",
"Visit",
"(",
"func",
"(",
"node",
"*",
"ZkNode",
",",
"ctxt",
"*",
"ZkNodeContext",
")",
"bool",
"{",
"if",
... | // returns a list of actions after taking a diff of in-memory ZK tree and live ZK tree. | [
"returns",
"a",
"list",
"of",
"actions",
"after",
"taking",
"a",
"diff",
"of",
"in",
"-",
"memory",
"ZK",
"tree",
"and",
"live",
"ZK",
"tree",
"."
] | 8a961ea3b25229b9b328724b8b2059ab58c1d16b | https://github.com/curator-go/curator/blob/8a961ea3b25229b9b328724b8b2059ab58c1d16b/examples/zktreeutil/zktree.go#L330-L346 |
148,716 | curator-go/curator | paths.go | SplitPath | func SplitPath(path string) (*PathAndNode, error) {
if idx := strings.LastIndex(path, PATH_SEPARATOR); idx < 0 {
return &PathAndNode{path, ""}, nil
} else if idx > 0 {
return &PathAndNode{path[:idx], path[idx+1:]}, nil
} else {
return &PathAndNode{PATH_SEPARATOR, path[idx+1:]}, nil
}
} | go | func SplitPath(path string) (*PathAndNode, error) {
if idx := strings.LastIndex(path, PATH_SEPARATOR); idx < 0 {
return &PathAndNode{path, ""}, nil
} else if idx > 0 {
return &PathAndNode{path[:idx], path[idx+1:]}, nil
} else {
return &PathAndNode{PATH_SEPARATOR, path[idx+1:]}, nil
}
} | [
"func",
"SplitPath",
"(",
"path",
"string",
")",
"(",
"*",
"PathAndNode",
",",
"error",
")",
"{",
"if",
"idx",
":=",
"strings",
".",
"LastIndex",
"(",
"path",
",",
"PATH_SEPARATOR",
")",
";",
"idx",
"<",
"0",
"{",
"return",
"&",
"PathAndNode",
"{",
"... | // Given a full path, return the the individual parts, without slashes. | [
"Given",
"a",
"full",
"path",
"return",
"the",
"the",
"individual",
"parts",
"without",
"slashes",
"."
] | 8a961ea3b25229b9b328724b8b2059ab58c1d16b | https://github.com/curator-go/curator/blob/8a961ea3b25229b9b328724b8b2059ab58c1d16b/paths.go#L34-L42 |
148,717 | curator-go/curator | paths.go | JoinPath | func JoinPath(parent string, children ...string) string {
path := new(bytes.Buffer)
if len(parent) > 0 {
if !strings.HasPrefix(parent, PATH_SEPARATOR) {
path.WriteString(PATH_SEPARATOR)
}
if strings.HasSuffix(parent, PATH_SEPARATOR) {
path.WriteString(parent[:len(parent)-1])
} else {
path.WriteStri... | go | func JoinPath(parent string, children ...string) string {
path := new(bytes.Buffer)
if len(parent) > 0 {
if !strings.HasPrefix(parent, PATH_SEPARATOR) {
path.WriteString(PATH_SEPARATOR)
}
if strings.HasSuffix(parent, PATH_SEPARATOR) {
path.WriteString(parent[:len(parent)-1])
} else {
path.WriteStri... | [
"func",
"JoinPath",
"(",
"parent",
"string",
",",
"children",
"...",
"string",
")",
"string",
"{",
"path",
":=",
"new",
"(",
"bytes",
".",
"Buffer",
")",
"\n\n",
"if",
"len",
"(",
"parent",
")",
">",
"0",
"{",
"if",
"!",
"strings",
".",
"HasPrefix",
... | // Given a parent and a child node, join them in the given path | [
"Given",
"a",
"parent",
"and",
"a",
"child",
"node",
"join",
"them",
"in",
"the",
"given",
"path"
] | 8a961ea3b25229b9b328724b8b2059ab58c1d16b | https://github.com/curator-go/curator/blob/8a961ea3b25229b9b328724b8b2059ab58c1d16b/paths.go#L45-L81 |
148,718 | curator-go/curator | paths.go | ValidatePath | func ValidatePath(path string) error {
if len(path) == 0 {
return errors.New("Path cannot be null")
}
if !strings.HasPrefix(path, PATH_SEPARATOR) {
return errors.New("Path must start with / character")
}
if len(path) == 1 {
return nil
}
if strings.HasSuffix(path, PATH_SEPARATOR) {
return errors.New("P... | go | func ValidatePath(path string) error {
if len(path) == 0 {
return errors.New("Path cannot be null")
}
if !strings.HasPrefix(path, PATH_SEPARATOR) {
return errors.New("Path must start with / character")
}
if len(path) == 1 {
return nil
}
if strings.HasSuffix(path, PATH_SEPARATOR) {
return errors.New("P... | [
"func",
"ValidatePath",
"(",
"path",
"string",
")",
"error",
"{",
"if",
"len",
"(",
"path",
")",
"==",
"0",
"{",
"return",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"if",
"!",
"strings",
".",
"HasPrefix",
"(",
"path",
",",
"P... | // Validate the provided znode path string | [
"Validate",
"the",
"provided",
"znode",
"path",
"string"
] | 8a961ea3b25229b9b328724b8b2059ab58c1d16b | https://github.com/curator-go/curator/blob/8a961ea3b25229b9b328724b8b2059ab58c1d16b/paths.go#L95-L137 |
148,719 | curator-go/curator | paths.go | MakeDirs | func MakeDirs(conn ZookeeperConnection, path string, makeLastNode bool, aclProvider ACLProvider) error {
if err := ValidatePath(path); err != nil {
return err
}
pos := 1 // skip first slash, root is guaranteed to exist
for pos < len(path) {
if idx := strings.Index(path[pos+1:], PATH_SEPARATOR); idx == -1 {
... | go | func MakeDirs(conn ZookeeperConnection, path string, makeLastNode bool, aclProvider ACLProvider) error {
if err := ValidatePath(path); err != nil {
return err
}
pos := 1 // skip first slash, root is guaranteed to exist
for pos < len(path) {
if idx := strings.Index(path[pos+1:], PATH_SEPARATOR); idx == -1 {
... | [
"func",
"MakeDirs",
"(",
"conn",
"ZookeeperConnection",
",",
"path",
"string",
",",
"makeLastNode",
"bool",
",",
"aclProvider",
"ACLProvider",
")",
"error",
"{",
"if",
"err",
":=",
"ValidatePath",
"(",
"path",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"... | // Make sure all the nodes in the path are created | [
"Make",
"sure",
"all",
"the",
"nodes",
"in",
"the",
"path",
"are",
"created"
] | 8a961ea3b25229b9b328724b8b2059ab58c1d16b | https://github.com/curator-go/curator/blob/8a961ea3b25229b9b328724b8b2059ab58c1d16b/paths.go#L140-L182 |
148,720 | curator-go/curator | paths.go | DeleteChildren | func DeleteChildren(conn ZookeeperConnection, path string, deleteSelf bool) error {
if err := ValidatePath(path); err != nil {
return err
}
if children, _, err := conn.Children(path); err != nil {
return err
} else {
for _, child := range children {
if err := DeleteChildren(conn, JoinPath(path, child), tr... | go | func DeleteChildren(conn ZookeeperConnection, path string, deleteSelf bool) error {
if err := ValidatePath(path); err != nil {
return err
}
if children, _, err := conn.Children(path); err != nil {
return err
} else {
for _, child := range children {
if err := DeleteChildren(conn, JoinPath(path, child), tr... | [
"func",
"DeleteChildren",
"(",
"conn",
"ZookeeperConnection",
",",
"path",
"string",
",",
"deleteSelf",
"bool",
")",
"error",
"{",
"if",
"err",
":=",
"ValidatePath",
"(",
"path",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"if"... | // Recursively deletes children of a node. | [
"Recursively",
"deletes",
"children",
"of",
"a",
"node",
"."
] | 8a961ea3b25229b9b328724b8b2059ab58c1d16b | https://github.com/curator-go/curator/blob/8a961ea3b25229b9b328724b8b2059ab58c1d16b/paths.go#L185-L214 |
148,721 | curator-go/curator | recipes/cache/child_data.go | NewChildData | func NewChildData(path string, stat *zk.Stat, data []byte) *ChildData {
return &ChildData{
path: path,
stat: stat,
data: data,
}
} | go | func NewChildData(path string, stat *zk.Stat, data []byte) *ChildData {
return &ChildData{
path: path,
stat: stat,
data: data,
}
} | [
"func",
"NewChildData",
"(",
"path",
"string",
",",
"stat",
"*",
"zk",
".",
"Stat",
",",
"data",
"[",
"]",
"byte",
")",
"*",
"ChildData",
"{",
"return",
"&",
"ChildData",
"{",
"path",
":",
"path",
",",
"stat",
":",
"stat",
",",
"data",
":",
"data",... | // NewChildData creates ChildData | [
"NewChildData",
"creates",
"ChildData"
] | 8a961ea3b25229b9b328724b8b2059ab58c1d16b | https://github.com/curator-go/curator/blob/8a961ea3b25229b9b328724b8b2059ab58c1d16b/recipes/cache/child_data.go#L13-L19 |
148,722 | curator-go/curator | recipes/conn.go | Future | func (c *AfterConnectionEstablished) Future() *promise.Future {
p := promise.NewPromise()
go func() {
if err := c.Client.BlockUntilConnectedTimeout(c.Timeout); err != nil {
p.Reject(err)
} else {
p.Resolve(p)
}
}()
return p.Future
} | go | func (c *AfterConnectionEstablished) Future() *promise.Future {
p := promise.NewPromise()
go func() {
if err := c.Client.BlockUntilConnectedTimeout(c.Timeout); err != nil {
p.Reject(err)
} else {
p.Resolve(p)
}
}()
return p.Future
} | [
"func",
"(",
"c",
"*",
"AfterConnectionEstablished",
")",
"Future",
"(",
")",
"*",
"promise",
".",
"Future",
"{",
"p",
":=",
"promise",
".",
"NewPromise",
"(",
")",
"\n\n",
"go",
"func",
"(",
")",
"{",
"if",
"err",
":=",
"c",
".",
"Client",
".",
"B... | // Spawns a new new background thread that will block
// until a connection is available and then execute the 'runAfterConnection' logic | [
"Spawns",
"a",
"new",
"new",
"background",
"thread",
"that",
"will",
"block",
"until",
"a",
"connection",
"is",
"available",
"and",
"then",
"execute",
"the",
"runAfterConnection",
"logic"
] | 8a961ea3b25229b9b328724b8b2059ab58c1d16b | https://github.com/curator-go/curator/blob/8a961ea3b25229b9b328724b8b2059ab58c1d16b/recipes/conn.go#L18-L30 |
148,723 | curator-go/curator | retry.go | ShouldRetry | func (l *retryLoop) ShouldRetry(err error) bool {
if err == zk.ErrSessionExpired || err == zk.ErrSessionMoved {
return true
}
if netErr, ok := err.(net.Error); ok {
return netErr.Timeout() || netErr.Temporary()
}
return false
} | go | func (l *retryLoop) ShouldRetry(err error) bool {
if err == zk.ErrSessionExpired || err == zk.ErrSessionMoved {
return true
}
if netErr, ok := err.(net.Error); ok {
return netErr.Timeout() || netErr.Temporary()
}
return false
} | [
"func",
"(",
"l",
"*",
"retryLoop",
")",
"ShouldRetry",
"(",
"err",
"error",
")",
"bool",
"{",
"if",
"err",
"==",
"zk",
".",
"ErrSessionExpired",
"||",
"err",
"==",
"zk",
".",
"ErrSessionMoved",
"{",
"return",
"true",
"\n",
"}",
"\n\n",
"if",
"netErr",... | // return true if the given Zookeeper result code is retry-able | [
"return",
"true",
"if",
"the",
"given",
"Zookeeper",
"result",
"code",
"is",
"retry",
"-",
"able"
] | 8a961ea3b25229b9b328724b8b2059ab58c1d16b | https://github.com/curator-go/curator/blob/8a961ea3b25229b9b328724b8b2059ab58c1d16b/retry.go#L60-L70 |
148,724 | curator-go/curator | state.go | SetHelper | func (h *handleHolder) SetHelper(helper zookeeperHelper) {
h.Lock()
defer h.Unlock()
h.helper = helper
} | go | func (h *handleHolder) SetHelper(helper zookeeperHelper) {
h.Lock()
defer h.Unlock()
h.helper = helper
} | [
"func",
"(",
"h",
"*",
"handleHolder",
")",
"SetHelper",
"(",
"helper",
"zookeeperHelper",
")",
"{",
"h",
".",
"Lock",
"(",
")",
"\n",
"defer",
"h",
".",
"Unlock",
"(",
")",
"\n",
"h",
".",
"helper",
"=",
"helper",
"\n",
"}"
] | // SetHelper sets the inner zookeeperHelper atomically | [
"SetHelper",
"sets",
"the",
"inner",
"zookeeperHelper",
"atomically"
] | 8a961ea3b25229b9b328724b8b2059ab58c1d16b | https://github.com/curator-go/curator/blob/8a961ea3b25229b9b328724b8b2059ab58c1d16b/state.go#L69-L73 |
148,725 | curator-go/curator | state.go | Helper | func (h *handleHolder) Helper() zookeeperHelper {
h.RLock()
defer h.RUnlock()
return h.helper
} | go | func (h *handleHolder) Helper() zookeeperHelper {
h.RLock()
defer h.RUnlock()
return h.helper
} | [
"func",
"(",
"h",
"*",
"handleHolder",
")",
"Helper",
"(",
")",
"zookeeperHelper",
"{",
"h",
".",
"RLock",
"(",
")",
"\n",
"defer",
"h",
".",
"RUnlock",
"(",
")",
"\n",
"return",
"h",
".",
"helper",
"\n",
"}"
] | // Helper gets the inner zookeeperHelper atomically | [
"Helper",
"gets",
"the",
"inner",
"zookeeperHelper",
"atomically"
] | 8a961ea3b25229b9b328724b8b2059ab58c1d16b | https://github.com/curator-go/curator/blob/8a961ea3b25229b9b328724b8b2059ab58c1d16b/state.go#L76-L80 |
148,726 | curator-go/curator | state.go | SetToSuspended | func (m *connectionStateManager) SetToSuspended() bool {
m.lock.Lock()
defer m.lock.Unlock()
if m.state.Value() != STARTED {
return false
}
if m.currentConnectionState == LOST || m.currentConnectionState == SUSPENDED {
return false
}
m.currentConnectionState = SUSPENDED
m.postState(SUSPENDED)
return t... | go | func (m *connectionStateManager) SetToSuspended() bool {
m.lock.Lock()
defer m.lock.Unlock()
if m.state.Value() != STARTED {
return false
}
if m.currentConnectionState == LOST || m.currentConnectionState == SUSPENDED {
return false
}
m.currentConnectionState = SUSPENDED
m.postState(SUSPENDED)
return t... | [
"func",
"(",
"m",
"*",
"connectionStateManager",
")",
"SetToSuspended",
"(",
")",
"bool",
"{",
"m",
".",
"lock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"m",
".",
"lock",
".",
"Unlock",
"(",
")",
"\n\n",
"if",
"m",
".",
"state",
".",
"Value",
"(",
... | // Change to ConnectionState.SUSPENDED only if not already suspended and not lost | [
"Change",
"to",
"ConnectionState",
".",
"SUSPENDED",
"only",
"if",
"not",
"already",
"suspended",
"and",
"not",
"lost"
] | 8a961ea3b25229b9b328724b8b2059ab58c1d16b | https://github.com/curator-go/curator/blob/8a961ea3b25229b9b328724b8b2059ab58c1d16b/state.go#L462-L479 |
148,727 | curator-go/curator | state.go | AddStateChange | func (m *connectionStateManager) AddStateChange(newConnectionState ConnectionState) bool {
m.lock.Lock()
defer m.lock.Unlock()
if m.state.Value() != STARTED {
return false
}
if m.currentConnectionState == newConnectionState {
return false
}
m.currentConnectionState = newConnectionState
localState := new... | go | func (m *connectionStateManager) AddStateChange(newConnectionState ConnectionState) bool {
m.lock.Lock()
defer m.lock.Unlock()
if m.state.Value() != STARTED {
return false
}
if m.currentConnectionState == newConnectionState {
return false
}
m.currentConnectionState = newConnectionState
localState := new... | [
"func",
"(",
"m",
"*",
"connectionStateManager",
")",
"AddStateChange",
"(",
"newConnectionState",
"ConnectionState",
")",
"bool",
"{",
"m",
".",
"lock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"m",
".",
"lock",
".",
"Unlock",
"(",
")",
"\n\n",
"if",
"m",
... | // Post a state change. If the manager is already in that state the change is ignored.
// Otherwise the change is queued for listeners. | [
"Post",
"a",
"state",
"change",
".",
"If",
"the",
"manager",
"is",
"already",
"in",
"that",
"state",
"the",
"change",
"is",
"ignored",
".",
"Otherwise",
"the",
"change",
"is",
"queued",
"for",
"listeners",
"."
] | 8a961ea3b25229b9b328724b8b2059ab58c1d16b | https://github.com/curator-go/curator/blob/8a961ea3b25229b9b328724b8b2059ab58c1d16b/state.go#L483-L511 |
148,728 | curator-go/curator | recipes/cache/tree_cache_event.go | String | func (et TreeCacheEventType) String() string {
switch et {
case TreeCacheEventNodeAdded:
return "NodeAdded"
case TreeCacheEventNodeUpdated:
return "NodeUpdated"
case TreeCacheEventNodeRemoved:
return "NodeRemoved"
case TreeCacheEventConnSuspended:
return "ConnSuspended"
case TreeCacheEventConnReconnected:... | go | func (et TreeCacheEventType) String() string {
switch et {
case TreeCacheEventNodeAdded:
return "NodeAdded"
case TreeCacheEventNodeUpdated:
return "NodeUpdated"
case TreeCacheEventNodeRemoved:
return "NodeRemoved"
case TreeCacheEventConnSuspended:
return "ConnSuspended"
case TreeCacheEventConnReconnected:... | [
"func",
"(",
"et",
"TreeCacheEventType",
")",
"String",
"(",
")",
"string",
"{",
"switch",
"et",
"{",
"case",
"TreeCacheEventNodeAdded",
":",
"return",
"\"",
"\"",
"\n",
"case",
"TreeCacheEventNodeUpdated",
":",
"return",
"\"",
"\"",
"\n",
"case",
"TreeCacheEv... | // String returns the string representation of TreeCacheEventType
// "Unknown" is returned when event type is unknown | [
"String",
"returns",
"the",
"string",
"representation",
"of",
"TreeCacheEventType",
"Unknown",
"is",
"returned",
"when",
"event",
"type",
"is",
"unknown"
] | 8a961ea3b25229b9b328724b8b2059ab58c1d16b | https://github.com/curator-go/curator/blob/8a961ea3b25229b9b328724b8b2059ab58c1d16b/recipes/cache/tree_cache_event.go#L28-L47 |
148,729 | curator-go/curator | recipes/cache/tree_cache_event.go | String | func (e TreeCacheEvent) String() string {
var path string
var data []byte
if e.Data != nil {
path = e.Data.Path()
data = e.Data.Data()
}
return fmt.Sprintf("TreeCacheEvent{%s %s '%s'}", e.Type, path, data)
} | go | func (e TreeCacheEvent) String() string {
var path string
var data []byte
if e.Data != nil {
path = e.Data.Path()
data = e.Data.Data()
}
return fmt.Sprintf("TreeCacheEvent{%s %s '%s'}", e.Type, path, data)
} | [
"func",
"(",
"e",
"TreeCacheEvent",
")",
"String",
"(",
")",
"string",
"{",
"var",
"path",
"string",
"\n",
"var",
"data",
"[",
"]",
"byte",
"\n",
"if",
"e",
".",
"Data",
"!=",
"nil",
"{",
"path",
"=",
"e",
".",
"Data",
".",
"Path",
"(",
")",
"\... | // String returns the string representation of TreeCacheEvent | [
"String",
"returns",
"the",
"string",
"representation",
"of",
"TreeCacheEvent"
] | 8a961ea3b25229b9b328724b8b2059ab58c1d16b | https://github.com/curator-go/curator/blob/8a961ea3b25229b9b328724b8b2059ab58c1d16b/recipes/cache/tree_cache_event.go#L56-L64 |
148,730 | curator-go/curator | recipes/cache/tree_node.go | SwapChildData | func (tn *TreeNode) SwapChildData(d *ChildData) *ChildData {
tn.Lock()
defer tn.Unlock()
old := tn.childData
tn.childData = d
return old
} | go | func (tn *TreeNode) SwapChildData(d *ChildData) *ChildData {
tn.Lock()
defer tn.Unlock()
old := tn.childData
tn.childData = d
return old
} | [
"func",
"(",
"tn",
"*",
"TreeNode",
")",
"SwapChildData",
"(",
"d",
"*",
"ChildData",
")",
"*",
"ChildData",
"{",
"tn",
".",
"Lock",
"(",
")",
"\n",
"defer",
"tn",
".",
"Unlock",
"(",
")",
"\n",
"old",
":=",
"tn",
".",
"childData",
"\n",
"tn",
".... | // SwapChildData sets ChildData to given value and returns the old ChildData. | [
"SwapChildData",
"sets",
"ChildData",
"to",
"given",
"value",
"and",
"returns",
"the",
"old",
"ChildData",
"."
] | 8a961ea3b25229b9b328724b8b2059ab58c1d16b | https://github.com/curator-go/curator/blob/8a961ea3b25229b9b328724b8b2059ab58c1d16b/recipes/cache/tree_node.go#L44-L50 |
148,731 | curator-go/curator | recipes/cache/tree_node.go | Children | func (tn *TreeNode) Children() map[string]*TreeNode {
tn.RLock()
defer tn.RUnlock()
children := make(map[string]*TreeNode, len(tn.children))
for k, v := range tn.children {
children[k] = v
}
return children
} | go | func (tn *TreeNode) Children() map[string]*TreeNode {
tn.RLock()
defer tn.RUnlock()
children := make(map[string]*TreeNode, len(tn.children))
for k, v := range tn.children {
children[k] = v
}
return children
} | [
"func",
"(",
"tn",
"*",
"TreeNode",
")",
"Children",
"(",
")",
"map",
"[",
"string",
"]",
"*",
"TreeNode",
"{",
"tn",
".",
"RLock",
"(",
")",
"\n",
"defer",
"tn",
".",
"RUnlock",
"(",
")",
"\n",
"children",
":=",
"make",
"(",
"map",
"[",
"string"... | // Children returns the children of current node. | [
"Children",
"returns",
"the",
"children",
"of",
"current",
"node",
"."
] | 8a961ea3b25229b9b328724b8b2059ab58c1d16b | https://github.com/curator-go/curator/blob/8a961ea3b25229b9b328724b8b2059ab58c1d16b/recipes/cache/tree_node.go#L53-L61 |
148,732 | curator-go/curator | recipes/cache/tree_node.go | ChildData | func (tn *TreeNode) ChildData() *ChildData {
tn.RLock()
defer tn.RUnlock()
return tn.childData
} | go | func (tn *TreeNode) ChildData() *ChildData {
tn.RLock()
defer tn.RUnlock()
return tn.childData
} | [
"func",
"(",
"tn",
"*",
"TreeNode",
")",
"ChildData",
"(",
")",
"*",
"ChildData",
"{",
"tn",
".",
"RLock",
"(",
")",
"\n",
"defer",
"tn",
".",
"RUnlock",
"(",
")",
"\n",
"return",
"tn",
".",
"childData",
"\n",
"}"
] | // ChildData returns the ChildData. | [
"ChildData",
"returns",
"the",
"ChildData",
"."
] | 8a961ea3b25229b9b328724b8b2059ab58c1d16b | https://github.com/curator-go/curator/blob/8a961ea3b25229b9b328724b8b2059ab58c1d16b/recipes/cache/tree_node.go#L73-L77 |
148,733 | curator-go/curator | recipes/cache/tree_node.go | RemoveChild | func (tn *TreeNode) RemoveChild(path string) {
tn.Lock()
defer tn.Unlock()
delete(tn.children, path)
} | go | func (tn *TreeNode) RemoveChild(path string) {
tn.Lock()
defer tn.Unlock()
delete(tn.children, path)
} | [
"func",
"(",
"tn",
"*",
"TreeNode",
")",
"RemoveChild",
"(",
"path",
"string",
")",
"{",
"tn",
".",
"Lock",
"(",
")",
"\n",
"defer",
"tn",
".",
"Unlock",
"(",
")",
"\n",
"delete",
"(",
"tn",
".",
"children",
",",
"path",
")",
"\n",
"}"
] | // RemoveChild removes child by path. | [
"RemoveChild",
"removes",
"child",
"by",
"path",
"."
] | 8a961ea3b25229b9b328724b8b2059ab58c1d16b | https://github.com/curator-go/curator/blob/8a961ea3b25229b9b328724b8b2059ab58c1d16b/recipes/cache/tree_node.go#L80-L84 |
148,734 | curator-go/curator | recipes/cache/tree_node.go | processWatchEvent | func (tn *TreeNode) processWatchEvent(evt *zk.Event) {
tn.tree.logger.Debugf("ProcessWatchEvent: %v", evt)
switch evt.Type {
case zk.EventNodeCreated:
if tn.parent != nil {
tn.tree.handleException(errors.New("unexpected NodeCreated on non-root node"))
return
}
tn.wasCreated()
case zk.EventNodeChildrenCh... | go | func (tn *TreeNode) processWatchEvent(evt *zk.Event) {
tn.tree.logger.Debugf("ProcessWatchEvent: %v", evt)
switch evt.Type {
case zk.EventNodeCreated:
if tn.parent != nil {
tn.tree.handleException(errors.New("unexpected NodeCreated on non-root node"))
return
}
tn.wasCreated()
case zk.EventNodeChildrenCh... | [
"func",
"(",
"tn",
"*",
"TreeNode",
")",
"processWatchEvent",
"(",
"evt",
"*",
"zk",
".",
"Event",
")",
"{",
"tn",
".",
"tree",
".",
"logger",
".",
"Debugf",
"(",
"\"",
"\"",
",",
"evt",
")",
"\n",
"switch",
"evt",
".",
"Type",
"{",
"case",
"zk",... | // processWatchEvent processes watch events. | [
"processWatchEvent",
"processes",
"watch",
"events",
"."
] | 8a961ea3b25229b9b328724b8b2059ab58c1d16b | https://github.com/curator-go/curator/blob/8a961ea3b25229b9b328724b8b2059ab58c1d16b/recipes/cache/tree_node.go#L161-L180 |
148,735 | curator-go/curator | recipes/cache/tree_cache_listener.go | ChildEvent | func (l *treeCacheListenerPrototype) ChildEvent(client curator.CuratorFramework, event TreeCacheEvent) error {
return l.childEvent(client, event)
} | go | func (l *treeCacheListenerPrototype) ChildEvent(client curator.CuratorFramework, event TreeCacheEvent) error {
return l.childEvent(client, event)
} | [
"func",
"(",
"l",
"*",
"treeCacheListenerPrototype",
")",
"ChildEvent",
"(",
"client",
"curator",
".",
"CuratorFramework",
",",
"event",
"TreeCacheEvent",
")",
"error",
"{",
"return",
"l",
".",
"childEvent",
"(",
"client",
",",
"event",
")",
"\n",
"}"
] | // ChildEvent is called when a change has occurred | [
"ChildEvent",
"is",
"called",
"when",
"a",
"change",
"has",
"occurred"
] | 8a961ea3b25229b9b328724b8b2059ab58c1d16b | https://github.com/curator-go/curator/blob/8a961ea3b25229b9b328724b8b2059ab58c1d16b/recipes/cache/tree_cache_listener.go#L20-L22 |
148,736 | curator-go/curator | recipes/cache/node_state.go | CompareAndSwap | func (s *NodeState) CompareAndSwap(old, new NodeState) bool {
return atomic.CompareAndSwapInt32((*int32)(s), int32(old), int32(new))
} | go | func (s *NodeState) CompareAndSwap(old, new NodeState) bool {
return atomic.CompareAndSwapInt32((*int32)(s), int32(old), int32(new))
} | [
"func",
"(",
"s",
"*",
"NodeState",
")",
"CompareAndSwap",
"(",
"old",
",",
"new",
"NodeState",
")",
"bool",
"{",
"return",
"atomic",
".",
"CompareAndSwapInt32",
"(",
"(",
"*",
"int32",
")",
"(",
"s",
")",
",",
"int32",
"(",
"old",
")",
",",
"int32",... | // CompareAndSwap set the state to new if value is old atomatically. | [
"CompareAndSwap",
"set",
"the",
"state",
"to",
"new",
"if",
"value",
"is",
"old",
"atomatically",
"."
] | 8a961ea3b25229b9b328724b8b2059ab58c1d16b | https://github.com/curator-go/curator/blob/8a961ea3b25229b9b328724b8b2059ab58c1d16b/recipes/cache/node_state.go#L22-L24 |
148,737 | curator-go/curator | recipes/cache/node_state.go | Store | func (s *NodeState) Store(new NodeState) {
atomic.StoreInt32((*int32)(s), int32(new))
} | go | func (s *NodeState) Store(new NodeState) {
atomic.StoreInt32((*int32)(s), int32(new))
} | [
"func",
"(",
"s",
"*",
"NodeState",
")",
"Store",
"(",
"new",
"NodeState",
")",
"{",
"atomic",
".",
"StoreInt32",
"(",
"(",
"*",
"int32",
")",
"(",
"s",
")",
",",
"int32",
"(",
"new",
")",
")",
"\n",
"}"
] | // Store sets the state to given value atomically. | [
"Store",
"sets",
"the",
"state",
"to",
"given",
"value",
"atomically",
"."
] | 8a961ea3b25229b9b328724b8b2059ab58c1d16b | https://github.com/curator-go/curator/blob/8a961ea3b25229b9b328724b8b2059ab58c1d16b/recipes/cache/node_state.go#L27-L29 |
148,738 | curator-go/curator | recipes/cache/node_state.go | Swap | func (s *NodeState) Swap(new NodeState) NodeState {
return NodeState(atomic.SwapInt32((*int32)(s), int32(new)))
} | go | func (s *NodeState) Swap(new NodeState) NodeState {
return NodeState(atomic.SwapInt32((*int32)(s), int32(new)))
} | [
"func",
"(",
"s",
"*",
"NodeState",
")",
"Swap",
"(",
"new",
"NodeState",
")",
"NodeState",
"{",
"return",
"NodeState",
"(",
"atomic",
".",
"SwapInt32",
"(",
"(",
"*",
"int32",
")",
"(",
"s",
")",
",",
"int32",
"(",
"new",
")",
")",
")",
"\n",
"}... | // Swap sets the state to given value and returns the old state atomically. | [
"Swap",
"sets",
"the",
"state",
"to",
"given",
"value",
"and",
"returns",
"the",
"old",
"state",
"atomically",
"."
] | 8a961ea3b25229b9b328724b8b2059ab58c1d16b | https://github.com/curator-go/curator/blob/8a961ea3b25229b9b328724b8b2059ab58c1d16b/recipes/cache/node_state.go#L32-L34 |
148,739 | curator-go/curator | trace.go | newTimeTracer | func newTimeTracer(name string, driver TracerDriver) *timeTracer {
return &timeTracer{
name: name,
driver: driver,
startTime: time.Now(),
}
} | go | func newTimeTracer(name string, driver TracerDriver) *timeTracer {
return &timeTracer{
name: name,
driver: driver,
startTime: time.Now(),
}
} | [
"func",
"newTimeTracer",
"(",
"name",
"string",
",",
"driver",
"TracerDriver",
")",
"*",
"timeTracer",
"{",
"return",
"&",
"timeTracer",
"{",
"name",
":",
"name",
",",
"driver",
":",
"driver",
",",
"startTime",
":",
"time",
".",
"Now",
"(",
")",
",",
"... | // Create and start a timer | [
"Create",
"and",
"start",
"a",
"timer"
] | 8a961ea3b25229b9b328724b8b2059ab58c1d16b | https://github.com/curator-go/curator/blob/8a961ea3b25229b9b328724b8b2059ab58c1d16b/trace.go#L63-L69 |
148,740 | curator-go/curator | trace.go | CommitAt | func (t *timeTracer) CommitAt(tm time.Time) {
t.driver.AddTime(t.name, tm.Sub(t.startTime))
} | go | func (t *timeTracer) CommitAt(tm time.Time) {
t.driver.AddTime(t.name, tm.Sub(t.startTime))
} | [
"func",
"(",
"t",
"*",
"timeTracer",
")",
"CommitAt",
"(",
"tm",
"time",
".",
"Time",
")",
"{",
"t",
".",
"driver",
".",
"AddTime",
"(",
"t",
".",
"name",
",",
"tm",
".",
"Sub",
"(",
"t",
".",
"startTime",
")",
")",
"\n",
"}"
] | // Record the elapsed time | [
"Record",
"the",
"elapsed",
"time"
] | 8a961ea3b25229b9b328724b8b2059ab58c1d16b | https://github.com/curator-go/curator/blob/8a961ea3b25229b9b328724b8b2059ab58c1d16b/trace.go#L77-L79 |
148,741 | scgolang/sc | synthdef.go | NewSynthdef | func NewSynthdef(name string, graphFunc UgenFunc) *Synthdef {
// It would be nice to parse synthdef params from function arguments
// with the reflect package.
// See https://groups.google.com/forum/#!topic/golang-nuts/nM_ZhL7fuGc
// for discussion of the (im)possibility of getting function argument
// names at ru... | go | func NewSynthdef(name string, graphFunc UgenFunc) *Synthdef {
// It would be nice to parse synthdef params from function arguments
// with the reflect package.
// See https://groups.google.com/forum/#!topic/golang-nuts/nM_ZhL7fuGc
// for discussion of the (im)possibility of getting function argument
// names at ru... | [
"func",
"NewSynthdef",
"(",
"name",
"string",
",",
"graphFunc",
"UgenFunc",
")",
"*",
"Synthdef",
"{",
"// It would be nice to parse synthdef params from function arguments",
"// with the reflect package.",
"// See https://groups.google.com/forum/#!topic/golang-nuts/nM_ZhL7fuGc",
"// f... | // NewSynthdef creates a synthdef by traversing a ugen graph | [
"NewSynthdef",
"creates",
"a",
"synthdef",
"by",
"traversing",
"a",
"ugen",
"graph"
] | 2b87756659e2b72d97cec43b6896ed01c0365097 | https://github.com/scgolang/sc/blob/2b87756659e2b72d97cec43b6896ed01c0365097/synthdef.go#L61-L77 |
148,742 | scgolang/sc | synthdef.go | Bytes | func (def *Synthdef) Bytes() ([]byte, error) {
arr := []byte{}
buf := bytes.NewBuffer(arr)
err := def.Write(buf)
if err != nil {
return arr, err
}
return buf.Bytes(), nil
} | go | func (def *Synthdef) Bytes() ([]byte, error) {
arr := []byte{}
buf := bytes.NewBuffer(arr)
err := def.Write(buf)
if err != nil {
return arr, err
}
return buf.Bytes(), nil
} | [
"func",
"(",
"def",
"*",
"Synthdef",
")",
"Bytes",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"arr",
":=",
"[",
"]",
"byte",
"{",
"}",
"\n",
"buf",
":=",
"bytes",
".",
"NewBuffer",
"(",
"arr",
")",
"\n",
"err",
":=",
"def",
".",... | // Bytes writes a synthdef to a byte array | [
"Bytes",
"writes",
"a",
"synthdef",
"to",
"a",
"byte",
"array"
] | 2b87756659e2b72d97cec43b6896ed01c0365097 | https://github.com/scgolang/sc/blob/2b87756659e2b72d97cec43b6896ed01c0365097/synthdef.go#L80-L88 |
148,743 | scgolang/sc | synthdef.go | CompareToFile | func (def *Synthdef) CompareToFile(path string) (bool, error) {
f, err := os.Open(path)
if err != nil {
return false, err
}
fromDisk, err := ioutil.ReadAll(f)
_ = f.Close() // Best effort.
if err != nil {
return false, err
}
buf := &bytes.Buffer{}
if err := def.Write(buf); err != nil {
return false, err
... | go | func (def *Synthdef) CompareToFile(path string) (bool, error) {
f, err := os.Open(path)
if err != nil {
return false, err
}
fromDisk, err := ioutil.ReadAll(f)
_ = f.Close() // Best effort.
if err != nil {
return false, err
}
buf := &bytes.Buffer{}
if err := def.Write(buf); err != nil {
return false, err
... | [
"func",
"(",
"def",
"*",
"Synthdef",
")",
"CompareToFile",
"(",
"path",
"string",
")",
"(",
"bool",
",",
"error",
")",
"{",
"f",
",",
"err",
":=",
"os",
".",
"Open",
"(",
"path",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"false",
",",
... | // CompareToFile compares this synthdef to another one stored on disk. | [
"CompareToFile",
"compares",
"this",
"synthdef",
"to",
"another",
"one",
"stored",
"on",
"disk",
"."
] | 2b87756659e2b72d97cec43b6896ed01c0365097 | https://github.com/scgolang/sc/blob/2b87756659e2b72d97cec43b6896ed01c0365097/synthdef.go#L91-L106 |
148,744 | scgolang/sc | synthdef.go | CompareToDef | func (def *Synthdef) CompareToDef(other *Synthdef) (bool, error) {
var (
buf1 = &bytes.Buffer{}
buf2 = &bytes.Buffer{}
)
if err := def.Write(buf1); err != nil {
return false, err
}
if err := other.Write(buf2); err != nil {
return false, err
}
return compareBytes(buf1.Bytes(), buf2.Bytes()), nil
} | go | func (def *Synthdef) CompareToDef(other *Synthdef) (bool, error) {
var (
buf1 = &bytes.Buffer{}
buf2 = &bytes.Buffer{}
)
if err := def.Write(buf1); err != nil {
return false, err
}
if err := other.Write(buf2); err != nil {
return false, err
}
return compareBytes(buf1.Bytes(), buf2.Bytes()), nil
} | [
"func",
"(",
"def",
"*",
"Synthdef",
")",
"CompareToDef",
"(",
"other",
"*",
"Synthdef",
")",
"(",
"bool",
",",
"error",
")",
"{",
"var",
"(",
"buf1",
"=",
"&",
"bytes",
".",
"Buffer",
"{",
"}",
"\n",
"buf2",
"=",
"&",
"bytes",
".",
"Buffer",
"{"... | // CompareToDef compare this synthdef to another. | [
"CompareToDef",
"compare",
"this",
"synthdef",
"to",
"another",
"."
] | 2b87756659e2b72d97cec43b6896ed01c0365097 | https://github.com/scgolang/sc/blob/2b87756659e2b72d97cec43b6896ed01c0365097/synthdef.go#L109-L121 |
148,745 | scgolang/sc | synthdef.go | Root | func (def *Synthdef) Root() int32 {
parents := make([]int, len(def.Ugens)) // Number of parents per ugen.
for _, u := range def.Ugens {
for _, in := range u.Inputs {
if in.IsConstant() {
continue
}
parents[in.UgenIndex]++
}
}
for i, count := range parents {
if count == 0 {
return int32(i)
}... | go | func (def *Synthdef) Root() int32 {
parents := make([]int, len(def.Ugens)) // Number of parents per ugen.
for _, u := range def.Ugens {
for _, in := range u.Inputs {
if in.IsConstant() {
continue
}
parents[in.UgenIndex]++
}
}
for i, count := range parents {
if count == 0 {
return int32(i)
}... | [
"func",
"(",
"def",
"*",
"Synthdef",
")",
"Root",
"(",
")",
"int32",
"{",
"parents",
":=",
"make",
"(",
"[",
"]",
"int",
",",
"len",
"(",
"def",
".",
"Ugens",
")",
")",
"// Number of parents per ugen.",
"\n\n",
"for",
"_",
",",
"u",
":=",
"range",
... | // Root returns the root node in the synthdef's ugen graph. | [
"Root",
"returns",
"the",
"root",
"node",
"in",
"the",
"synthdef",
"s",
"ugen",
"graph",
"."
] | 2b87756659e2b72d97cec43b6896ed01c0365097 | https://github.com/scgolang/sc/blob/2b87756659e2b72d97cec43b6896ed01c0365097/synthdef.go#L132-L149 |
148,746 | scgolang/sc | synthdef.go | addConstant | func (def *Synthdef) addConstant(c C) int {
for i, f := range def.Constants {
if f == float32(c) {
return i
}
}
l := len(def.Constants)
def.Constants = append(def.Constants, float32(c))
return l
} | go | func (def *Synthdef) addConstant(c C) int {
for i, f := range def.Constants {
if f == float32(c) {
return i
}
}
l := len(def.Constants)
def.Constants = append(def.Constants, float32(c))
return l
} | [
"func",
"(",
"def",
"*",
"Synthdef",
")",
"addConstant",
"(",
"c",
"C",
")",
"int",
"{",
"for",
"i",
",",
"f",
":=",
"range",
"def",
".",
"Constants",
"{",
"if",
"f",
"==",
"float32",
"(",
"c",
")",
"{",
"return",
"i",
"\n",
"}",
"\n",
"}",
"... | // addConstant adds a constant to a synthdef and returns
// the index in the constants array where that constant is
// located.
// It ensures that constants are not added twice by returning the
// position in the constants array of the existing constant if
// you try to add a duplicate. | [
"addConstant",
"adds",
"a",
"constant",
"to",
"a",
"synthdef",
"and",
"returns",
"the",
"index",
"in",
"the",
"constants",
"array",
"where",
"that",
"constant",
"is",
"located",
".",
"It",
"ensures",
"that",
"constants",
"are",
"not",
"added",
"twice",
"by",... | 2b87756659e2b72d97cec43b6896ed01c0365097 | https://github.com/scgolang/sc/blob/2b87756659e2b72d97cec43b6896ed01c0365097/synthdef.go#L157-L166 |
148,747 | scgolang/sc | synthdef.go | addUgen | func (def *Synthdef) addUgen(u *Ugen) (*Ugen, int, bool) {
for i, un := range def.seen {
if un == u {
return def.Ugens[i], i, true
}
}
def.seen = append(def.seen, u)
idx := len(def.Ugens)
ugen := cloneUgen(u)
def.Ugens = append(def.Ugens, ugen)
return ugen, idx, false
} | go | func (def *Synthdef) addUgen(u *Ugen) (*Ugen, int, bool) {
for i, un := range def.seen {
if un == u {
return def.Ugens[i], i, true
}
}
def.seen = append(def.seen, u)
idx := len(def.Ugens)
ugen := cloneUgen(u)
def.Ugens = append(def.Ugens, ugen)
return ugen, idx, false
} | [
"func",
"(",
"def",
"*",
"Synthdef",
")",
"addUgen",
"(",
"u",
"*",
"Ugen",
")",
"(",
"*",
"Ugen",
",",
"int",
",",
"bool",
")",
"{",
"for",
"i",
",",
"un",
":=",
"range",
"def",
".",
"seen",
"{",
"if",
"un",
"==",
"u",
"{",
"return",
"def",
... | // addUgen adds a Ugen to a synthdef and returns
// the ugen that was added, the position in the ugens array, and
// a flag indicating whether this is a new ugen or one that
// has already been visited. | [
"addUgen",
"adds",
"a",
"Ugen",
"to",
"a",
"synthdef",
"and",
"returns",
"the",
"ugen",
"that",
"was",
"added",
"the",
"position",
"in",
"the",
"ugens",
"array",
"and",
"a",
"flag",
"indicating",
"whether",
"this",
"is",
"a",
"new",
"ugen",
"or",
"one",
... | 2b87756659e2b72d97cec43b6896ed01c0365097 | https://github.com/scgolang/sc/blob/2b87756659e2b72d97cec43b6896ed01c0365097/synthdef.go#L197-L208 |
148,748 | scgolang/sc | synthdef.go | flattenInput | func (def *Synthdef) flattenInput(params Params, ugen *Ugen, input Input) {
switch v := input.(type) {
case *Ugen:
_, idx, _ := def.addUgen(v)
// In has different behavior than other ugens when it is multichannel expanded.
// Each channel of its output gets mapped to a single channel of the expression
// tre... | go | func (def *Synthdef) flattenInput(params Params, ugen *Ugen, input Input) {
switch v := input.(type) {
case *Ugen:
_, idx, _ := def.addUgen(v)
// In has different behavior than other ugens when it is multichannel expanded.
// Each channel of its output gets mapped to a single channel of the expression
// tre... | [
"func",
"(",
"def",
"*",
"Synthdef",
")",
"flattenInput",
"(",
"params",
"Params",
",",
"ugen",
"*",
"Ugen",
",",
"input",
"Input",
")",
"{",
"switch",
"v",
":=",
"input",
".",
"(",
"type",
")",
"{",
"case",
"*",
"Ugen",
":",
"_",
",",
"idx",
","... | // flattenInput flattens a ugen graph starting from a particular ugen's input. | [
"flattenInput",
"flattens",
"a",
"ugen",
"graph",
"starting",
"from",
"a",
"particular",
"ugen",
"s",
"input",
"."
] | 2b87756659e2b72d97cec43b6896ed01c0365097 | https://github.com/scgolang/sc/blob/2b87756659e2b72d97cec43b6896ed01c0365097/synthdef.go#L232-L291 |
148,749 | scgolang/sc | synthdef.go | processUgenInput | func (def *Synthdef) processUgenInput(input Input, stack *stack, depth int) {
switch v := input.(type) {
case *Ugen:
def.topsortr(v, stack, depth+1)
break
case MultiInput:
// multi input
mins := v.InputArray()
for j := len(mins) - 1; j >= 0; j-- {
switch w := mins[j].(type) {
case *Ugen:
def.tops... | go | func (def *Synthdef) processUgenInput(input Input, stack *stack, depth int) {
switch v := input.(type) {
case *Ugen:
def.topsortr(v, stack, depth+1)
break
case MultiInput:
// multi input
mins := v.InputArray()
for j := len(mins) - 1; j >= 0; j-- {
switch w := mins[j].(type) {
case *Ugen:
def.tops... | [
"func",
"(",
"def",
"*",
"Synthdef",
")",
"processUgenInput",
"(",
"input",
"Input",
",",
"stack",
"*",
"stack",
",",
"depth",
"int",
")",
"{",
"switch",
"v",
":=",
"input",
".",
"(",
"type",
")",
"{",
"case",
"*",
"Ugen",
":",
"def",
".",
"topsort... | // processUgenInput processes a single ugen input | [
"processUgenInput",
"processes",
"a",
"single",
"ugen",
"input"
] | 2b87756659e2b72d97cec43b6896ed01c0365097 | https://github.com/scgolang/sc/blob/2b87756659e2b72d97cec43b6896ed01c0365097/synthdef.go#L294-L311 |
148,750 | scgolang/sc | synthdef.go | topsort | func (def *Synthdef) topsort(root *Ugen) []*Ugen {
stack := newStack()
def.topsortr(root, stack, 0)
var (
i = 0
n = stack.Size()
ugens = make([]*Ugen, n)
)
for v := stack.Pop(); v != nil; v = stack.Pop() {
ugens[i] = v.(*Ugen)
i = i + 1
}
return ugens
} | go | func (def *Synthdef) topsort(root *Ugen) []*Ugen {
stack := newStack()
def.topsortr(root, stack, 0)
var (
i = 0
n = stack.Size()
ugens = make([]*Ugen, n)
)
for v := stack.Pop(); v != nil; v = stack.Pop() {
ugens[i] = v.(*Ugen)
i = i + 1
}
return ugens
} | [
"func",
"(",
"def",
"*",
"Synthdef",
")",
"topsort",
"(",
"root",
"*",
"Ugen",
")",
"[",
"]",
"*",
"Ugen",
"{",
"stack",
":=",
"newStack",
"(",
")",
"\n\n",
"def",
".",
"topsortr",
"(",
"root",
",",
"stack",
",",
"0",
")",
"\n\n",
"var",
"(",
"... | // topsort performs a depth-first-search of a ugen tree | [
"topsort",
"performs",
"a",
"depth",
"-",
"first",
"-",
"search",
"of",
"a",
"ugen",
"tree"
] | 2b87756659e2b72d97cec43b6896ed01c0365097 | https://github.com/scgolang/sc/blob/2b87756659e2b72d97cec43b6896ed01c0365097/synthdef.go#L314-L329 |
148,751 | scgolang/sc | synthdef.go | topsortr | func (def *Synthdef) topsortr(root *Ugen, stack *stack, depth int) {
stack.Push(root)
var (
inputs = root.inputs
numInputs = len(inputs)
)
for i := numInputs - 1; i >= 0; i-- {
def.processUgenInput(inputs[i], stack, depth)
}
} | go | func (def *Synthdef) topsortr(root *Ugen, stack *stack, depth int) {
stack.Push(root)
var (
inputs = root.inputs
numInputs = len(inputs)
)
for i := numInputs - 1; i >= 0; i-- {
def.processUgenInput(inputs[i], stack, depth)
}
} | [
"func",
"(",
"def",
"*",
"Synthdef",
")",
"topsortr",
"(",
"root",
"*",
"Ugen",
",",
"stack",
"*",
"stack",
",",
"depth",
"int",
")",
"{",
"stack",
".",
"Push",
"(",
"root",
")",
"\n\n",
"var",
"(",
"inputs",
"=",
"root",
".",
"inputs",
"\n",
"nu... | // topsortr performs a depth-first-search of a ugen tree starting at a given depth. | [
"topsortr",
"performs",
"a",
"depth",
"-",
"first",
"-",
"search",
"of",
"a",
"ugen",
"tree",
"starting",
"at",
"a",
"given",
"depth",
"."
] | 2b87756659e2b72d97cec43b6896ed01c0365097 | https://github.com/scgolang/sc/blob/2b87756659e2b72d97cec43b6896ed01c0365097/synthdef.go#L332-L342 |
148,752 | scgolang/sc | synthdef.go | compareBytes | func compareBytes(a, b []byte) bool {
la, lb := len(a), len(b)
if la != lb {
return false
}
for i, octet := range a {
if octet != b[i] {
return false
}
}
return true
} | go | func compareBytes(a, b []byte) bool {
la, lb := len(a), len(b)
if la != lb {
return false
}
for i, octet := range a {
if octet != b[i] {
return false
}
}
return true
} | [
"func",
"compareBytes",
"(",
"a",
",",
"b",
"[",
"]",
"byte",
")",
"bool",
"{",
"la",
",",
"lb",
":=",
"len",
"(",
"a",
")",
",",
"len",
"(",
"b",
")",
"\n",
"if",
"la",
"!=",
"lb",
"{",
"return",
"false",
"\n",
"}",
"\n",
"for",
"i",
",",
... | // compareBytes returns true if two byte arrays
// are identical, false if they are not | [
"compareBytes",
"returns",
"true",
"if",
"two",
"byte",
"arrays",
"are",
"identical",
"false",
"if",
"they",
"are",
"not"
] | 2b87756659e2b72d97cec43b6896ed01c0365097 | https://github.com/scgolang/sc/blob/2b87756659e2b72d97cec43b6896ed01c0365097/synthdef.go#L346-L357 |
148,753 | scgolang/sc | synthdef.go | do | func (d differ) do() [][2]string {
// Early out if they have different numbers of ugens or constants.
if l1, l2 := len(d[0].Ugens), len(d[1].Ugens); l1 != l2 {
return [][2]string{
{
fmt.Sprintf("%d ugens", l1),
fmt.Sprintf("%d ugens", l2),
},
}
}
if l1, l2 := len(d[0].Constants), len(d[1].Constant... | go | func (d differ) do() [][2]string {
// Early out if they have different numbers of ugens or constants.
if l1, l2 := len(d[0].Ugens), len(d[1].Ugens); l1 != l2 {
return [][2]string{
{
fmt.Sprintf("%d ugens", l1),
fmt.Sprintf("%d ugens", l2),
},
}
}
if l1, l2 := len(d[0].Constants), len(d[1].Constant... | [
"func",
"(",
"d",
"differ",
")",
"do",
"(",
")",
"[",
"]",
"[",
"2",
"]",
"string",
"{",
"// Early out if they have different numbers of ugens or constants.",
"if",
"l1",
",",
"l2",
":=",
"len",
"(",
"d",
"[",
"0",
"]",
".",
"Ugens",
")",
",",
"len",
"... | // do performs a diff.
// The diff shows whether one ugen graph differs structurally from another.
// If the returned slice is empty it means the synthdefs are structurally identical. | [
"do",
"performs",
"a",
"diff",
".",
"The",
"diff",
"shows",
"whether",
"one",
"ugen",
"graph",
"differs",
"structurally",
"from",
"another",
".",
"If",
"the",
"returned",
"slice",
"is",
"empty",
"it",
"means",
"the",
"synthdefs",
"are",
"structurally",
"iden... | 2b87756659e2b72d97cec43b6896ed01c0365097 | https://github.com/scgolang/sc/blob/2b87756659e2b72d97cec43b6896ed01c0365097/synthdef.go#L441-L460 |
148,754 | scgolang/sc | variant.go | Write | func (variant *Variant) Write(w io.Writer) error {
if err := newPstring(variant.Name).Write(w); err != nil {
return err
}
for _, v := range variant.InitialParamValues {
if err := binary.Write(w, byteOrder, v); err != nil {
return err
}
}
return nil
} | go | func (variant *Variant) Write(w io.Writer) error {
if err := newPstring(variant.Name).Write(w); err != nil {
return err
}
for _, v := range variant.InitialParamValues {
if err := binary.Write(w, byteOrder, v); err != nil {
return err
}
}
return nil
} | [
"func",
"(",
"variant",
"*",
"Variant",
")",
"Write",
"(",
"w",
"io",
".",
"Writer",
")",
"error",
"{",
"if",
"err",
":=",
"newPstring",
"(",
"variant",
".",
"Name",
")",
".",
"Write",
"(",
"w",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",... | // Write writes a variant to an io.Writer. | [
"Write",
"writes",
"a",
"variant",
"to",
"an",
"io",
".",
"Writer",
"."
] | 2b87756659e2b72d97cec43b6896ed01c0365097 | https://github.com/scgolang/sc/blob/2b87756659e2b72d97cec43b6896ed01c0365097/variant.go#L15-L25 |
148,755 | scgolang/sc | variant.go | readVariant | func readVariant(r io.Reader, numParams int32) (*Variant, error) {
name, err := readPstring(r)
if err != nil {
return nil, err
}
paramValues := make([]float32, numParams)
for i := 0; int32(i) < numParams; i++ {
if err := binary.Read(r, byteOrder, ¶mValues[i]); err != nil {
return nil, err
}
}
v := V... | go | func readVariant(r io.Reader, numParams int32) (*Variant, error) {
name, err := readPstring(r)
if err != nil {
return nil, err
}
paramValues := make([]float32, numParams)
for i := 0; int32(i) < numParams; i++ {
if err := binary.Read(r, byteOrder, ¶mValues[i]); err != nil {
return nil, err
}
}
v := V... | [
"func",
"readVariant",
"(",
"r",
"io",
".",
"Reader",
",",
"numParams",
"int32",
")",
"(",
"*",
"Variant",
",",
"error",
")",
"{",
"name",
",",
"err",
":=",
"readPstring",
"(",
"r",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
... | // readVariant read a Variant from an io.Reader | [
"readVariant",
"read",
"a",
"Variant",
"from",
"an",
"io",
".",
"Reader"
] | 2b87756659e2b72d97cec43b6896ed01c0365097 | https://github.com/scgolang/sc/blob/2b87756659e2b72d97cec43b6896ed01c0365097/variant.go#L28-L41 |
148,756 | scgolang/sc | leakdc.go | Rate | func (ldc LeakDC) Rate(rate int8) Input {
CheckRate(rate)
if ldc.In == nil {
panic("LeakDC requires an input signal")
}
ldc.rate = rate
(&ldc).defaults()
return NewInput("LeakDC", rate, 0, 1, ldc.In, ldc.Coeff)
} | go | func (ldc LeakDC) Rate(rate int8) Input {
CheckRate(rate)
if ldc.In == nil {
panic("LeakDC requires an input signal")
}
ldc.rate = rate
(&ldc).defaults()
return NewInput("LeakDC", rate, 0, 1, ldc.In, ldc.Coeff)
} | [
"func",
"(",
"ldc",
"LeakDC",
")",
"Rate",
"(",
"rate",
"int8",
")",
"Input",
"{",
"CheckRate",
"(",
"rate",
")",
"\n",
"if",
"ldc",
".",
"In",
"==",
"nil",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"ldc",
".",
"rate",
"=",
"rate",
... | // Rate creates a new ugen at a specific rate.
// If rate is an unsupported value this method will cause a runtime panic.
// If the input signal is nil this method will cause a runtime panic. | [
"Rate",
"creates",
"a",
"new",
"ugen",
"at",
"a",
"specific",
"rate",
".",
"If",
"rate",
"is",
"an",
"unsupported",
"value",
"this",
"method",
"will",
"cause",
"a",
"runtime",
"panic",
".",
"If",
"the",
"input",
"signal",
"is",
"nil",
"this",
"method",
... | 2b87756659e2b72d97cec43b6896ed01c0365097 | https://github.com/scgolang/sc/blob/2b87756659e2b72d97cec43b6896ed01c0365097/leakdc.go#L28-L36 |
148,757 | scgolang/sc | arrayspec.go | Add | func (as ArraySpec) Add(val Input) Input {
return as.proc(func(i Input) Input {
return i.Add(val)
})
} | go | func (as ArraySpec) Add(val Input) Input {
return as.proc(func(i Input) Input {
return i.Add(val)
})
} | [
"func",
"(",
"as",
"ArraySpec",
")",
"Add",
"(",
"val",
"Input",
")",
"Input",
"{",
"return",
"as",
".",
"proc",
"(",
"func",
"(",
"i",
"Input",
")",
"Input",
"{",
"return",
"i",
".",
"Add",
"(",
"val",
")",
"\n",
"}",
")",
"\n",
"}"
] | // Add adds one input to another. | [
"Add",
"adds",
"one",
"input",
"to",
"another",
"."
] | 2b87756659e2b72d97cec43b6896ed01c0365097 | https://github.com/scgolang/sc/blob/2b87756659e2b72d97cec43b6896ed01c0365097/arrayspec.go#L32-L36 |
148,758 | scgolang/sc | arrayspec.go | Ceil | func (as ArraySpec) Ceil() Input {
return as.proc(func(i Input) Input {
return i.Ceil()
})
} | go | func (as ArraySpec) Ceil() Input {
return as.proc(func(i Input) Input {
return i.Ceil()
})
} | [
"func",
"(",
"as",
"ArraySpec",
")",
"Ceil",
"(",
")",
"Input",
"{",
"return",
"as",
".",
"proc",
"(",
"func",
"(",
"i",
"Input",
")",
"Input",
"{",
"return",
"i",
".",
"Ceil",
"(",
")",
"\n",
"}",
")",
"\n",
"}"
] | // Ceil computes the ceiling of a signal. | [
"Ceil",
"computes",
"the",
"ceiling",
"of",
"a",
"signal",
"."
] | 2b87756659e2b72d97cec43b6896ed01c0365097 | https://github.com/scgolang/sc/blob/2b87756659e2b72d97cec43b6896ed01c0365097/arrayspec.go#L81-L85 |
148,759 | scgolang/sc | arrayspec.go | Cos | func (as ArraySpec) Cos() Input {
return as.proc(func(i Input) Input {
return i.Cos()
})
} | go | func (as ArraySpec) Cos() Input {
return as.proc(func(i Input) Input {
return i.Cos()
})
} | [
"func",
"(",
"as",
"ArraySpec",
")",
"Cos",
"(",
")",
"Input",
"{",
"return",
"as",
".",
"proc",
"(",
"func",
"(",
"i",
"Input",
")",
"Input",
"{",
"return",
"i",
".",
"Cos",
"(",
")",
"\n",
"}",
")",
"\n",
"}"
] | // Cos computes the cosine of a signal. | [
"Cos",
"computes",
"the",
"cosine",
"of",
"a",
"signal",
"."
] | 2b87756659e2b72d97cec43b6896ed01c0365097 | https://github.com/scgolang/sc/blob/2b87756659e2b72d97cec43b6896ed01c0365097/arrayspec.go#L102-L106 |
148,760 | scgolang/sc | arrayspec.go | Cosh | func (as ArraySpec) Cosh() Input {
return as.proc(func(i Input) Input {
return i.Cosh()
})
} | go | func (as ArraySpec) Cosh() Input {
return as.proc(func(i Input) Input {
return i.Cosh()
})
} | [
"func",
"(",
"as",
"ArraySpec",
")",
"Cosh",
"(",
")",
"Input",
"{",
"return",
"as",
".",
"proc",
"(",
"func",
"(",
"i",
"Input",
")",
"Input",
"{",
"return",
"i",
".",
"Cosh",
"(",
")",
"\n",
"}",
")",
"\n",
"}"
] | // Cosh computes the hyperbolic cosine of a signal. | [
"Cosh",
"computes",
"the",
"hyperbolic",
"cosine",
"of",
"a",
"signal",
"."
] | 2b87756659e2b72d97cec43b6896ed01c0365097 | https://github.com/scgolang/sc/blob/2b87756659e2b72d97cec43b6896ed01c0365097/arrayspec.go#L109-L113 |
148,761 | scgolang/sc | arrayspec.go | DbAmp | func (as ArraySpec) DbAmp() Input {
return as.proc(func(i Input) Input {
return i.DbAmp()
})
} | go | func (as ArraySpec) DbAmp() Input {
return as.proc(func(i Input) Input {
return i.DbAmp()
})
} | [
"func",
"(",
"as",
"ArraySpec",
")",
"DbAmp",
"(",
")",
"Input",
"{",
"return",
"as",
".",
"proc",
"(",
"func",
"(",
"i",
"Input",
")",
"Input",
"{",
"return",
"i",
".",
"DbAmp",
"(",
")",
"\n",
"}",
")",
"\n",
"}"
] | // DbAmp converts decibels tolinear amplitude. | [
"DbAmp",
"converts",
"decibels",
"tolinear",
"amplitude",
"."
] | 2b87756659e2b72d97cec43b6896ed01c0365097 | https://github.com/scgolang/sc/blob/2b87756659e2b72d97cec43b6896ed01c0365097/arrayspec.go#L137-L141 |
148,762 | scgolang/sc | arrayspec.go | Expon | func (as ArraySpec) Expon(val Input) Input {
return as.proc(func(i Input) Input {
return i.Expon(val)
})
} | go | func (as ArraySpec) Expon(val Input) Input {
return as.proc(func(i Input) Input {
return i.Expon(val)
})
} | [
"func",
"(",
"as",
"ArraySpec",
")",
"Expon",
"(",
"val",
"Input",
")",
"Input",
"{",
"return",
"as",
".",
"proc",
"(",
"func",
"(",
"i",
"Input",
")",
"Input",
"{",
"return",
"i",
".",
"Expon",
"(",
"val",
")",
"\n",
"}",
")",
"\n",
"}"
] | // Expon raises an Input to the power of another. | [
"Expon",
"raises",
"an",
"Input",
"to",
"the",
"power",
"of",
"another",
"."
] | 2b87756659e2b72d97cec43b6896ed01c0365097 | https://github.com/scgolang/sc/blob/2b87756659e2b72d97cec43b6896ed01c0365097/arrayspec.go#L179-L183 |
148,763 | scgolang/sc | arrayspec.go | Floor | func (as ArraySpec) Floor() Input {
return as.proc(func(i Input) Input {
return i.Floor()
})
} | go | func (as ArraySpec) Floor() Input {
return as.proc(func(i Input) Input {
return i.Floor()
})
} | [
"func",
"(",
"as",
"ArraySpec",
")",
"Floor",
"(",
")",
"Input",
"{",
"return",
"as",
".",
"proc",
"(",
"func",
"(",
"i",
"Input",
")",
"Input",
"{",
"return",
"i",
".",
"Floor",
"(",
")",
"\n",
"}",
")",
"\n",
"}"
] | // Floor computes the floor of a signal. | [
"Floor",
"computes",
"the",
"floor",
"of",
"a",
"signal",
"."
] | 2b87756659e2b72d97cec43b6896ed01c0365097 | https://github.com/scgolang/sc/blob/2b87756659e2b72d97cec43b6896ed01c0365097/arrayspec.go#L186-L190 |
148,764 | scgolang/sc | arrayspec.go | Frac | func (as ArraySpec) Frac() Input {
return as.proc(func(i Input) Input {
return i.Frac()
})
} | go | func (as ArraySpec) Frac() Input {
return as.proc(func(i Input) Input {
return i.Frac()
})
} | [
"func",
"(",
"as",
"ArraySpec",
")",
"Frac",
"(",
")",
"Input",
"{",
"return",
"as",
".",
"proc",
"(",
"func",
"(",
"i",
"Input",
")",
"Input",
"{",
"return",
"i",
".",
"Frac",
"(",
")",
"\n",
"}",
")",
"\n",
"}"
] | // Frac returns the fractional part of a signal. | [
"Frac",
"returns",
"the",
"fractional",
"part",
"of",
"a",
"signal",
"."
] | 2b87756659e2b72d97cec43b6896ed01c0365097 | https://github.com/scgolang/sc/blob/2b87756659e2b72d97cec43b6896ed01c0365097/arrayspec.go#L200-L204 |
148,765 | scgolang/sc | arrayspec.go | Midicps | func (as ArraySpec) Midicps() Input {
return as.proc(func(i Input) Input {
return i.Midicps()
})
} | go | func (as ArraySpec) Midicps() Input {
return as.proc(func(i Input) Input {
return i.Midicps()
})
} | [
"func",
"(",
"as",
"ArraySpec",
")",
"Midicps",
"(",
")",
"Input",
"{",
"return",
"as",
".",
"proc",
"(",
"func",
"(",
"i",
"Input",
")",
"Input",
"{",
"return",
"i",
".",
"Midicps",
"(",
")",
"\n",
"}",
")",
"\n",
"}"
] | // Midicps converts from MIDI note values to cycles per second. | [
"Midicps",
"converts",
"from",
"MIDI",
"note",
"values",
"to",
"cycles",
"per",
"second",
"."
] | 2b87756659e2b72d97cec43b6896ed01c0365097 | https://github.com/scgolang/sc/blob/2b87756659e2b72d97cec43b6896ed01c0365097/arrayspec.go#L306-L310 |
148,766 | scgolang/sc | arrayspec.go | Mul | func (as ArraySpec) Mul(val Input) Input {
return as.proc(func(i Input) Input {
return i.Mul(val)
})
} | go | func (as ArraySpec) Mul(val Input) Input {
return as.proc(func(i Input) Input {
return i.Mul(val)
})
} | [
"func",
"(",
"as",
"ArraySpec",
")",
"Mul",
"(",
"val",
"Input",
")",
"Input",
"{",
"return",
"as",
".",
"proc",
"(",
"func",
"(",
"i",
"Input",
")",
"Input",
"{",
"return",
"i",
".",
"Mul",
"(",
"val",
")",
"\n",
"}",
")",
"\n",
"}"
] | // Mul multiplies one input and another. | [
"Mul",
"multiplies",
"one",
"input",
"and",
"another",
"."
] | 2b87756659e2b72d97cec43b6896ed01c0365097 | https://github.com/scgolang/sc/blob/2b87756659e2b72d97cec43b6896ed01c0365097/arrayspec.go#L334-L338 |
148,767 | scgolang/sc | arrayspec.go | Neg | func (as ArraySpec) Neg() Input {
return as.proc(func(i Input) Input {
return i.Neg()
})
} | go | func (as ArraySpec) Neg() Input {
return as.proc(func(i Input) Input {
return i.Neg()
})
} | [
"func",
"(",
"as",
"ArraySpec",
")",
"Neg",
"(",
")",
"Input",
"{",
"return",
"as",
".",
"proc",
"(",
"func",
"(",
"i",
"Input",
")",
"Input",
"{",
"return",
"i",
".",
"Neg",
"(",
")",
"\n",
"}",
")",
"\n",
"}"
] | // Neg negates an input. | [
"Neg",
"negates",
"an",
"input",
"."
] | 2b87756659e2b72d97cec43b6896ed01c0365097 | https://github.com/scgolang/sc/blob/2b87756659e2b72d97cec43b6896ed01c0365097/arrayspec.go#L348-L352 |
148,768 | scgolang/sc | arrayspec.go | Pow | func (as ArraySpec) Pow(val Input) Input {
return as.proc(func(i Input) Input {
return i.Pow(val)
})
} | go | func (as ArraySpec) Pow(val Input) Input {
return as.proc(func(i Input) Input {
return i.Pow(val)
})
} | [
"func",
"(",
"as",
"ArraySpec",
")",
"Pow",
"(",
"val",
"Input",
")",
"Input",
"{",
"return",
"as",
".",
"proc",
"(",
"func",
"(",
"i",
"Input",
")",
"Input",
"{",
"return",
"i",
".",
"Pow",
"(",
"val",
")",
"\n",
"}",
")",
"\n",
"}"
] | // Pow raises an Input to the power of another. | [
"Pow",
"raises",
"an",
"Input",
"to",
"the",
"power",
"of",
"another",
"."
] | 2b87756659e2b72d97cec43b6896ed01c0365097 | https://github.com/scgolang/sc/blob/2b87756659e2b72d97cec43b6896ed01c0365097/arrayspec.go#L362-L366 |
148,769 | scgolang/sc | arrayspec.go | Sign | func (as ArraySpec) Sign() Input {
return as.proc(func(i Input) Input {
return i.Sign()
})
} | go | func (as ArraySpec) Sign() Input {
return as.proc(func(i Input) Input {
return i.Sign()
})
} | [
"func",
"(",
"as",
"ArraySpec",
")",
"Sign",
"(",
")",
"Input",
"{",
"return",
"as",
".",
"proc",
"(",
"func",
"(",
"i",
"Input",
")",
"Input",
"{",
"return",
"i",
".",
"Sign",
"(",
")",
"\n",
"}",
")",
"\n",
"}"
] | // Sign returns the sign of a signal. | [
"Sign",
"returns",
"the",
"sign",
"of",
"a",
"signal",
"."
] | 2b87756659e2b72d97cec43b6896ed01c0365097 | https://github.com/scgolang/sc/blob/2b87756659e2b72d97cec43b6896ed01c0365097/arrayspec.go#L439-L443 |
148,770 | scgolang/sc | arrayspec.go | Sin | func (as ArraySpec) Sin() Input {
return as.proc(func(i Input) Input {
return i.Sin()
})
} | go | func (as ArraySpec) Sin() Input {
return as.proc(func(i Input) Input {
return i.Sin()
})
} | [
"func",
"(",
"as",
"ArraySpec",
")",
"Sin",
"(",
")",
"Input",
"{",
"return",
"as",
".",
"proc",
"(",
"func",
"(",
"i",
"Input",
")",
"Input",
"{",
"return",
"i",
".",
"Sin",
"(",
")",
"\n",
"}",
")",
"\n",
"}"
] | // Sin computes the sine of a signal. | [
"Sin",
"computes",
"the",
"sine",
"of",
"a",
"signal",
"."
] | 2b87756659e2b72d97cec43b6896ed01c0365097 | https://github.com/scgolang/sc/blob/2b87756659e2b72d97cec43b6896ed01c0365097/arrayspec.go#L446-L450 |
148,771 | scgolang/sc | arrayspec.go | Sinh | func (as ArraySpec) Sinh() Input {
return as.proc(func(i Input) Input {
return i.Sinh()
})
} | go | func (as ArraySpec) Sinh() Input {
return as.proc(func(i Input) Input {
return i.Sinh()
})
} | [
"func",
"(",
"as",
"ArraySpec",
")",
"Sinh",
"(",
")",
"Input",
"{",
"return",
"as",
".",
"proc",
"(",
"func",
"(",
"i",
"Input",
")",
"Input",
"{",
"return",
"i",
".",
"Sinh",
"(",
")",
"\n",
"}",
")",
"\n",
"}"
] | // Sinh computes the hyperbolic sine of a signal. | [
"Sinh",
"computes",
"the",
"hyperbolic",
"sine",
"of",
"a",
"signal",
"."
] | 2b87756659e2b72d97cec43b6896ed01c0365097 | https://github.com/scgolang/sc/blob/2b87756659e2b72d97cec43b6896ed01c0365097/arrayspec.go#L453-L457 |
148,772 | scgolang/sc | arrayspec.go | SoftClip | func (as ArraySpec) SoftClip() Input {
return as.proc(func(i Input) Input {
return i.SoftClip()
})
} | go | func (as ArraySpec) SoftClip() Input {
return as.proc(func(i Input) Input {
return i.SoftClip()
})
} | [
"func",
"(",
"as",
"ArraySpec",
")",
"SoftClip",
"(",
")",
"Input",
"{",
"return",
"as",
".",
"proc",
"(",
"func",
"(",
"i",
"Input",
")",
"Input",
"{",
"return",
"i",
".",
"SoftClip",
"(",
")",
"\n",
"}",
")",
"\n",
"}"
] | // SoftClip computes nonlinear distortion of an input. | [
"SoftClip",
"computes",
"nonlinear",
"distortion",
"of",
"an",
"input",
"."
] | 2b87756659e2b72d97cec43b6896ed01c0365097 | https://github.com/scgolang/sc/blob/2b87756659e2b72d97cec43b6896ed01c0365097/arrayspec.go#L460-L464 |
148,773 | scgolang/sc | arrayspec.go | Sqrt | func (as ArraySpec) Sqrt() Input {
return as.proc(func(i Input) Input {
return i.Sqrt()
})
} | go | func (as ArraySpec) Sqrt() Input {
return as.proc(func(i Input) Input {
return i.Sqrt()
})
} | [
"func",
"(",
"as",
"ArraySpec",
")",
"Sqrt",
"(",
")",
"Input",
"{",
"return",
"as",
".",
"proc",
"(",
"func",
"(",
"i",
"Input",
")",
"Input",
"{",
"return",
"i",
".",
"Sqrt",
"(",
")",
"\n",
"}",
")",
"\n",
"}"
] | // Sqrt returns the square root of a signal. | [
"Sqrt",
"returns",
"the",
"square",
"root",
"of",
"a",
"signal",
"."
] | 2b87756659e2b72d97cec43b6896ed01c0365097 | https://github.com/scgolang/sc/blob/2b87756659e2b72d97cec43b6896ed01c0365097/arrayspec.go#L481-L485 |
148,774 | scgolang/sc | arrayspec.go | Tan | func (as ArraySpec) Tan() Input {
return as.proc(func(i Input) Input {
return i.Tan()
})
} | go | func (as ArraySpec) Tan() Input {
return as.proc(func(i Input) Input {
return i.Tan()
})
} | [
"func",
"(",
"as",
"ArraySpec",
")",
"Tan",
"(",
")",
"Input",
"{",
"return",
"as",
".",
"proc",
"(",
"func",
"(",
"i",
"Input",
")",
"Input",
"{",
"return",
"i",
".",
"Tan",
"(",
")",
"\n",
"}",
")",
"\n",
"}"
] | // Tan computes the tangent of a signal. | [
"Tan",
"computes",
"the",
"tangent",
"of",
"a",
"signal",
"."
] | 2b87756659e2b72d97cec43b6896ed01c0365097 | https://github.com/scgolang/sc/blob/2b87756659e2b72d97cec43b6896ed01c0365097/arrayspec.go#L509-L513 |
148,775 | scgolang/sc | arrayspec.go | Tanh | func (as ArraySpec) Tanh() Input {
return as.proc(func(i Input) Input {
return i.Tanh()
})
} | go | func (as ArraySpec) Tanh() Input {
return as.proc(func(i Input) Input {
return i.Tanh()
})
} | [
"func",
"(",
"as",
"ArraySpec",
")",
"Tanh",
"(",
")",
"Input",
"{",
"return",
"as",
".",
"proc",
"(",
"func",
"(",
"i",
"Input",
")",
"Input",
"{",
"return",
"i",
".",
"Tanh",
"(",
")",
"\n",
"}",
")",
"\n",
"}"
] | // Tanh computes the hyperbolic tangent of a signal. | [
"Tanh",
"computes",
"the",
"hyperbolic",
"tangent",
"of",
"a",
"signal",
"."
] | 2b87756659e2b72d97cec43b6896ed01c0365097 | https://github.com/scgolang/sc/blob/2b87756659e2b72d97cec43b6896ed01c0365097/arrayspec.go#L516-L520 |
148,776 | scgolang/sc | arrayspec.go | proc | func (as ArraySpec) proc(f func(Input) Input) Input {
var nas ArraySpec
for i := range []int{0, 1, 2} {
for j := range nas[i] {
nas[i][j] = f(as[i][j])
}
}
return nas
} | go | func (as ArraySpec) proc(f func(Input) Input) Input {
var nas ArraySpec
for i := range []int{0, 1, 2} {
for j := range nas[i] {
nas[i][j] = f(as[i][j])
}
}
return nas
} | [
"func",
"(",
"as",
"ArraySpec",
")",
"proc",
"(",
"f",
"func",
"(",
"Input",
")",
"Input",
")",
"Input",
"{",
"var",
"nas",
"ArraySpec",
"\n",
"for",
"i",
":=",
"range",
"[",
"]",
"int",
"{",
"0",
",",
"1",
",",
"2",
"}",
"{",
"for",
"j",
":=... | // proc processes the inputs in this arrayspec | [
"proc",
"processes",
"the",
"inputs",
"in",
"this",
"arrayspec"
] | 2b87756659e2b72d97cec43b6896ed01c0365097 | https://github.com/scgolang/sc/blob/2b87756659e2b72d97cec43b6896ed01c0365097/arrayspec.go#L588-L596 |
148,777 | scgolang/sc | output.go | Write | func (o Output) Write(w io.Writer) error {
return binary.Write(w, byteOrder, int8(o))
} | go | func (o Output) Write(w io.Writer) error {
return binary.Write(w, byteOrder, int8(o))
} | [
"func",
"(",
"o",
"Output",
")",
"Write",
"(",
"w",
"io",
".",
"Writer",
")",
"error",
"{",
"return",
"binary",
".",
"Write",
"(",
"w",
",",
"byteOrder",
",",
"int8",
"(",
"o",
")",
")",
"\n",
"}"
] | // Write writes the output to an io.Writer. | [
"Write",
"writes",
"the",
"output",
"to",
"an",
"io",
".",
"Writer",
"."
] | 2b87756659e2b72d97cec43b6896ed01c0365097 | https://github.com/scgolang/sc/blob/2b87756659e2b72d97cec43b6896ed01c0365097/output.go#L12-L14 |
148,778 | scgolang/sc | client.go | NewClient | func NewClient(network, local, scsynth string, timeout time.Duration) (*Client, error) {
addr, err := net.ResolveUDPAddr(network, local)
if err != nil {
return nil, err
}
c := &Client{
errChan: make(chan error),
bufferInfoChan: make(chan osc.Message),
doneChan: make(chan osc.Message, numDoneHan... | go | func NewClient(network, local, scsynth string, timeout time.Duration) (*Client, error) {
addr, err := net.ResolveUDPAddr(network, local)
if err != nil {
return nil, err
}
c := &Client{
errChan: make(chan error),
bufferInfoChan: make(chan osc.Message),
doneChan: make(chan osc.Message, numDoneHan... | [
"func",
"NewClient",
"(",
"network",
",",
"local",
",",
"scsynth",
"string",
",",
"timeout",
"time",
".",
"Duration",
")",
"(",
"*",
"Client",
",",
"error",
")",
"{",
"addr",
",",
"err",
":=",
"net",
".",
"ResolveUDPAddr",
"(",
"network",
",",
"local",... | // NewClient creates a new SuperCollider client.
// The client will bind to the provided address and port
// to receive messages from scsynth. | [
"NewClient",
"creates",
"a",
"new",
"SuperCollider",
"client",
".",
"The",
"client",
"will",
"bind",
"to",
"the",
"provided",
"address",
"and",
"port",
"to",
"receive",
"messages",
"from",
"scsynth",
"."
] | 2b87756659e2b72d97cec43b6896ed01c0365097 | https://github.com/scgolang/sc/blob/2b87756659e2b72d97cec43b6896ed01c0365097/client.go#L115-L133 |
148,779 | scgolang/sc | client.go | DefaultClient | func DefaultClient() (*Client, error) {
var err error
if defaultClient == nil {
defaultClient, err = NewClient("udp", DefaultLocalAddr, DefaultScsynthAddr, DefaultConnectTimeout)
if err != nil {
return nil, err
}
defaultGroup, err = defaultClient.AddDefaultGroup()
if err != nil {
return nil, err
}
... | go | func DefaultClient() (*Client, error) {
var err error
if defaultClient == nil {
defaultClient, err = NewClient("udp", DefaultLocalAddr, DefaultScsynthAddr, DefaultConnectTimeout)
if err != nil {
return nil, err
}
defaultGroup, err = defaultClient.AddDefaultGroup()
if err != nil {
return nil, err
}
... | [
"func",
"DefaultClient",
"(",
")",
"(",
"*",
"Client",
",",
"error",
")",
"{",
"var",
"err",
"error",
"\n\n",
"if",
"defaultClient",
"==",
"nil",
"{",
"defaultClient",
",",
"err",
"=",
"NewClient",
"(",
"\"",
"\"",
",",
"DefaultLocalAddr",
",",
"DefaultS... | // DefaultClient returns the default sc client. | [
"DefaultClient",
"returns",
"the",
"default",
"sc",
"client",
"."
] | 2b87756659e2b72d97cec43b6896ed01c0365097 | https://github.com/scgolang/sc/blob/2b87756659e2b72d97cec43b6896ed01c0365097/client.go#L141-L155 |
148,780 | scgolang/sc | client.go | AddDefaultGroup | func (c *Client) AddDefaultGroup() (*GroupNode, error) {
return c.Group(DefaultGroupID, AddToTail, RootNodeID)
} | go | func (c *Client) AddDefaultGroup() (*GroupNode, error) {
return c.Group(DefaultGroupID, AddToTail, RootNodeID)
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"AddDefaultGroup",
"(",
")",
"(",
"*",
"GroupNode",
",",
"error",
")",
"{",
"return",
"c",
".",
"Group",
"(",
"DefaultGroupID",
",",
"AddToTail",
",",
"RootNodeID",
")",
"\n",
"}"
] | // AddDefaultGroup adds the default group. | [
"AddDefaultGroup",
"adds",
"the",
"default",
"group",
"."
] | 2b87756659e2b72d97cec43b6896ed01c0365097 | https://github.com/scgolang/sc/blob/2b87756659e2b72d97cec43b6896ed01c0365097/client.go#L158-L160 |
148,781 | scgolang/sc | client.go | Connect | func (c *Client) Connect(addr string, timeout time.Duration) error {
raddr, err := net.ResolveUDPAddr("udp", addr)
if err != nil {
return err
}
// Attempt connection with a timeout.
var (
start = time.Now()
timedOut = true
)
for time.Now().Sub(start) < timeout {
oscConn, err := osc.DialUDP("udp", c.a... | go | func (c *Client) Connect(addr string, timeout time.Duration) error {
raddr, err := net.ResolveUDPAddr("udp", addr)
if err != nil {
return err
}
// Attempt connection with a timeout.
var (
start = time.Now()
timedOut = true
)
for time.Now().Sub(start) < timeout {
oscConn, err := osc.DialUDP("udp", c.a... | [
"func",
"(",
"c",
"*",
"Client",
")",
"Connect",
"(",
"addr",
"string",
",",
"timeout",
"time",
".",
"Duration",
")",
"error",
"{",
"raddr",
",",
"err",
":=",
"net",
".",
"ResolveUDPAddr",
"(",
"\"",
"\"",
",",
"addr",
")",
"\n",
"if",
"err",
"!=",... | // Connect connects to an scsynth instance via UDP. | [
"Connect",
"connects",
"to",
"an",
"scsynth",
"instance",
"via",
"UDP",
"."
] | 2b87756659e2b72d97cec43b6896ed01c0365097 | https://github.com/scgolang/sc/blob/2b87756659e2b72d97cec43b6896ed01c0365097/client.go#L163-L207 |
148,782 | scgolang/sc | client.go | FreeAll | func (c *Client) FreeAll(gids ...int32) error {
msg := osc.Message{
Address: groupFreeAllAddress,
}
for _, gid := range gids {
msg.Arguments = append(msg.Arguments, osc.Int(gid))
}
return c.oscConn.Send(msg)
} | go | func (c *Client) FreeAll(gids ...int32) error {
msg := osc.Message{
Address: groupFreeAllAddress,
}
for _, gid := range gids {
msg.Arguments = append(msg.Arguments, osc.Int(gid))
}
return c.oscConn.Send(msg)
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"FreeAll",
"(",
"gids",
"...",
"int32",
")",
"error",
"{",
"msg",
":=",
"osc",
".",
"Message",
"{",
"Address",
":",
"groupFreeAllAddress",
",",
"}",
"\n",
"for",
"_",
",",
"gid",
":=",
"range",
"gids",
"{",
"ms... | // FreeAll frees all nodes in a group | [
"FreeAll",
"frees",
"all",
"nodes",
"in",
"a",
"group"
] | 2b87756659e2b72d97cec43b6896ed01c0365097 | https://github.com/scgolang/sc/blob/2b87756659e2b72d97cec43b6896ed01c0365097/client.go#L221-L229 |
148,783 | scgolang/sc | client.go | Group | func (c *Client) Group(id, action, target int32) (*GroupNode, error) {
msg := osc.Message{
Address: groupNewAddress,
Arguments: osc.Arguments{
osc.Int(id),
osc.Int(action),
osc.Int(target),
},
}
if err := c.oscConn.Send(msg); err != nil {
return nil, err
}
return newGroup(c, id), nil
} | go | func (c *Client) Group(id, action, target int32) (*GroupNode, error) {
msg := osc.Message{
Address: groupNewAddress,
Arguments: osc.Arguments{
osc.Int(id),
osc.Int(action),
osc.Int(target),
},
}
if err := c.oscConn.Send(msg); err != nil {
return nil, err
}
return newGroup(c, id), nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"Group",
"(",
"id",
",",
"action",
",",
"target",
"int32",
")",
"(",
"*",
"GroupNode",
",",
"error",
")",
"{",
"msg",
":=",
"osc",
".",
"Message",
"{",
"Address",
":",
"groupNewAddress",
",",
"Arguments",
":",
... | // Group creates a group. | [
"Group",
"creates",
"a",
"group",
"."
] | 2b87756659e2b72d97cec43b6896ed01c0365097 | https://github.com/scgolang/sc/blob/2b87756659e2b72d97cec43b6896ed01c0365097/client.go#L232-L245 |
148,784 | scgolang/sc | client.go | NodeFree | func (c *Client) NodeFree(id int32) error {
return c.oscConn.Send(osc.Message{
Address: nodeFreeAddress,
Arguments: osc.Arguments{osc.Int(id)},
})
} | go | func (c *Client) NodeFree(id int32) error {
return c.oscConn.Send(osc.Message{
Address: nodeFreeAddress,
Arguments: osc.Arguments{osc.Int(id)},
})
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"NodeFree",
"(",
"id",
"int32",
")",
"error",
"{",
"return",
"c",
".",
"oscConn",
".",
"Send",
"(",
"osc",
".",
"Message",
"{",
"Address",
":",
"nodeFreeAddress",
",",
"Arguments",
":",
"osc",
".",
"Arguments",
"... | // NodeFree stops a node abruptly, removes it from its group, and frees its memory.
// Using this method can cause a click if the node is not silent at the time it is freed. | [
"NodeFree",
"stops",
"a",
"node",
"abruptly",
"removes",
"it",
"from",
"its",
"group",
"and",
"frees",
"its",
"memory",
".",
"Using",
"this",
"method",
"can",
"cause",
"a",
"click",
"if",
"the",
"node",
"is",
"not",
"silent",
"at",
"the",
"time",
"it",
... | 2b87756659e2b72d97cec43b6896ed01c0365097 | https://github.com/scgolang/sc/blob/2b87756659e2b72d97cec43b6896ed01c0365097/client.go#L254-L259 |
148,785 | scgolang/sc | client.go | NodeMap | func (c *Client) NodeMap(id int32, m map[string]int32) error {
msg := osc.Message{
Address: nodeMapAddress,
Arguments: osc.Arguments{
osc.Int(id),
},
}
for k, v := range m {
msg.Arguments = append(msg.Arguments, osc.String(k))
msg.Arguments = append(msg.Arguments, osc.Int(v))
}
return c.oscConn.Send(m... | go | func (c *Client) NodeMap(id int32, m map[string]int32) error {
msg := osc.Message{
Address: nodeMapAddress,
Arguments: osc.Arguments{
osc.Int(id),
},
}
for k, v := range m {
msg.Arguments = append(msg.Arguments, osc.String(k))
msg.Arguments = append(msg.Arguments, osc.Int(v))
}
return c.oscConn.Send(m... | [
"func",
"(",
"c",
"*",
"Client",
")",
"NodeMap",
"(",
"id",
"int32",
",",
"m",
"map",
"[",
"string",
"]",
"int32",
")",
"error",
"{",
"msg",
":=",
"osc",
".",
"Message",
"{",
"Address",
":",
"nodeMapAddress",
",",
"Arguments",
":",
"osc",
".",
"Arg... | // NodeMap causes controls of a node to be read from a control bus.
// The first argument is the node ID.
// The second argument is a map from control names to control bus indices. | [
"NodeMap",
"causes",
"controls",
"of",
"a",
"node",
"to",
"be",
"read",
"from",
"a",
"control",
"bus",
".",
"The",
"first",
"argument",
"is",
"the",
"node",
"ID",
".",
"The",
"second",
"argument",
"is",
"a",
"map",
"from",
"control",
"names",
"to",
"co... | 2b87756659e2b72d97cec43b6896ed01c0365097 | https://github.com/scgolang/sc/blob/2b87756659e2b72d97cec43b6896ed01c0365097/client.go#L264-L276 |
148,786 | scgolang/sc | client.go | NodeSet | func (c *Client) NodeSet(id int32, ctls map[string]float32) error {
msg := osc.Message{
Address: nodeSetAddress,
Arguments: osc.Arguments{
osc.Int(id),
},
}
for k, v := range ctls {
msg.Arguments = append(msg.Arguments, osc.String(k))
msg.Arguments = append(msg.Arguments, osc.Float(v))
}
return c.oscC... | go | func (c *Client) NodeSet(id int32, ctls map[string]float32) error {
msg := osc.Message{
Address: nodeSetAddress,
Arguments: osc.Arguments{
osc.Int(id),
},
}
for k, v := range ctls {
msg.Arguments = append(msg.Arguments, osc.String(k))
msg.Arguments = append(msg.Arguments, osc.Float(v))
}
return c.oscC... | [
"func",
"(",
"c",
"*",
"Client",
")",
"NodeSet",
"(",
"id",
"int32",
",",
"ctls",
"map",
"[",
"string",
"]",
"float32",
")",
"error",
"{",
"msg",
":=",
"osc",
".",
"Message",
"{",
"Address",
":",
"nodeSetAddress",
",",
"Arguments",
":",
"osc",
".",
... | // NodeSet sets a control value on a node. | [
"NodeSet",
"sets",
"a",
"control",
"value",
"on",
"a",
"node",
"."
] | 2b87756659e2b72d97cec43b6896ed01c0365097 | https://github.com/scgolang/sc/blob/2b87756659e2b72d97cec43b6896ed01c0365097/client.go#L296-L308 |
148,787 | scgolang/sc | client.go | QueryGroup | func (c *Client) QueryGroup(id int32) (*GroupNode, error) {
if err := c.oscConn.Send(osc.Message{
Address: groupQueryTreeAddress,
Arguments: osc.Arguments{
osc.Int(id),
osc.Int(1),
},
}); err != nil {
return nil, err
}
// wait for response
var resp osc.Message
select {
case resp = <-c.gqueryTreeCha... | go | func (c *Client) QueryGroup(id int32) (*GroupNode, error) {
if err := c.oscConn.Send(osc.Message{
Address: groupQueryTreeAddress,
Arguments: osc.Arguments{
osc.Int(id),
osc.Int(1),
},
}); err != nil {
return nil, err
}
// wait for response
var resp osc.Message
select {
case resp = <-c.gqueryTreeCha... | [
"func",
"(",
"c",
"*",
"Client",
")",
"QueryGroup",
"(",
"id",
"int32",
")",
"(",
"*",
"GroupNode",
",",
"error",
")",
"{",
"if",
"err",
":=",
"c",
".",
"oscConn",
".",
"Send",
"(",
"osc",
".",
"Message",
"{",
"Address",
":",
"groupQueryTreeAddress",... | // QueryGroup g_queryTree for a particular group. | [
"QueryGroup",
"g_queryTree",
"for",
"a",
"particular",
"group",
"."
] | 2b87756659e2b72d97cec43b6896ed01c0365097 | https://github.com/scgolang/sc/blob/2b87756659e2b72d97cec43b6896ed01c0365097/client.go#L311-L335 |
148,788 | scgolang/sc | client.go | SendAllDefs | func (c *Client) SendAllDefs() error {
// If you add to this map, please keep the keys in alphabetical order.
for name, f := range map[string]UgenFunc{
"grainbuf_mono": defGrainBuf(1),
"grainbuf_stereo": defGrainBuf(2),
"in": defIn,
"jpverb": defJPverb,
"lfo": defLFO,
"... | go | func (c *Client) SendAllDefs() error {
// If you add to this map, please keep the keys in alphabetical order.
for name, f := range map[string]UgenFunc{
"grainbuf_mono": defGrainBuf(1),
"grainbuf_stereo": defGrainBuf(2),
"in": defIn,
"jpverb": defJPverb,
"lfo": defLFO,
"... | [
"func",
"(",
"c",
"*",
"Client",
")",
"SendAllDefs",
"(",
")",
"error",
"{",
"// If you add to this map, please keep the keys in alphabetical order.",
"for",
"name",
",",
"f",
":=",
"range",
"map",
"[",
"string",
"]",
"UgenFunc",
"{",
"\"",
"\"",
":",
"defGrainB... | // SendAllDefs sends all the synthdefs that have been registered with RegisterSynthdef. | [
"SendAllDefs",
"sends",
"all",
"the",
"synthdefs",
"that",
"have",
"been",
"registered",
"with",
"RegisterSynthdef",
"."
] | 2b87756659e2b72d97cec43b6896ed01c0365097 | https://github.com/scgolang/sc/blob/2b87756659e2b72d97cec43b6896ed01c0365097/client.go#L338-L356 |
148,789 | scgolang/sc | client.go | Status | func (c *Client) Status(timeout time.Duration) (*ServerStatus, error) {
statusReq := osc.Message{
Address: statusAddress,
}
if err := c.oscConn.Send(statusReq); err != nil {
return nil, err
}
after := time.After(timeout)
select {
case _ = <-after:
return nil, ErrTimeout
case msg := <-c.statusChan:
ret... | go | func (c *Client) Status(timeout time.Duration) (*ServerStatus, error) {
statusReq := osc.Message{
Address: statusAddress,
}
if err := c.oscConn.Send(statusReq); err != nil {
return nil, err
}
after := time.After(timeout)
select {
case _ = <-after:
return nil, ErrTimeout
case msg := <-c.statusChan:
ret... | [
"func",
"(",
"c",
"*",
"Client",
")",
"Status",
"(",
"timeout",
"time",
".",
"Duration",
")",
"(",
"*",
"ServerStatus",
",",
"error",
")",
"{",
"statusReq",
":=",
"osc",
".",
"Message",
"{",
"Address",
":",
"statusAddress",
",",
"}",
"\n",
"if",
"err... | // Status gets the status of scsynth with a timeout.
// If the status request times out it returns ErrTimeout. | [
"Status",
"gets",
"the",
"status",
"of",
"scsynth",
"with",
"a",
"timeout",
".",
"If",
"the",
"status",
"request",
"times",
"out",
"it",
"returns",
"ErrTimeout",
"."
] | 2b87756659e2b72d97cec43b6896ed01c0365097 | https://github.com/scgolang/sc/blob/2b87756659e2b72d97cec43b6896ed01c0365097/client.go#L401-L419 |
148,790 | scgolang/sc | client.go | Synth | func (c *Client) Synth(defName string, id, action, target int32, ctls map[string]float32) (*Synth, error) {
msg := osc.Message{
Address: synthNewAddress,
Arguments: osc.Arguments{
osc.String(defName),
osc.Int(id),
osc.Int(action),
osc.Int(target),
},
}
if ctls != nil {
for k, v := range ctls {
... | go | func (c *Client) Synth(defName string, id, action, target int32, ctls map[string]float32) (*Synth, error) {
msg := osc.Message{
Address: synthNewAddress,
Arguments: osc.Arguments{
osc.String(defName),
osc.Int(id),
osc.Int(action),
osc.Int(target),
},
}
if ctls != nil {
for k, v := range ctls {
... | [
"func",
"(",
"c",
"*",
"Client",
")",
"Synth",
"(",
"defName",
"string",
",",
"id",
",",
"action",
",",
"target",
"int32",
",",
"ctls",
"map",
"[",
"string",
"]",
"float32",
")",
"(",
"*",
"Synth",
",",
"error",
")",
"{",
"msg",
":=",
"osc",
".",... | // Synth creates a synth node. | [
"Synth",
"creates",
"a",
"synth",
"node",
"."
] | 2b87756659e2b72d97cec43b6896ed01c0365097 | https://github.com/scgolang/sc/blob/2b87756659e2b72d97cec43b6896ed01c0365097/client.go#L422-L442 |
148,791 | scgolang/sc | client.go | oscHandlers | func (c *Client) oscHandlers() osc.Dispatcher {
return map[string]osc.MessageHandler{
bufferInfoAddress: osc.Method(func(msg osc.Message) error {
c.bufferInfoChan <- msg
return nil
}),
statusReplyAddress: osc.Method(func(msg osc.Message) error {
c.statusChan <- msg
return nil
}),
doneOscAddress: ... | go | func (c *Client) oscHandlers() osc.Dispatcher {
return map[string]osc.MessageHandler{
bufferInfoAddress: osc.Method(func(msg osc.Message) error {
c.bufferInfoChan <- msg
return nil
}),
statusReplyAddress: osc.Method(func(msg osc.Message) error {
c.statusChan <- msg
return nil
}),
doneOscAddress: ... | [
"func",
"(",
"c",
"*",
"Client",
")",
"oscHandlers",
"(",
")",
"osc",
".",
"Dispatcher",
"{",
"return",
"map",
"[",
"string",
"]",
"osc",
".",
"MessageHandler",
"{",
"bufferInfoAddress",
":",
"osc",
".",
"Method",
"(",
"func",
"(",
"msg",
"osc",
".",
... | // addOscHandlers adds OSC handlers | [
"addOscHandlers",
"adds",
"OSC",
"handlers"
] | 2b87756659e2b72d97cec43b6896ed01c0365097 | https://github.com/scgolang/sc/blob/2b87756659e2b72d97cec43b6896ed01c0365097/client.go#L478-L497 |
148,792 | scgolang/sc | client.go | PlayDef | func PlayDef(def *Synthdef) (*Synth, error) {
c, err := DefaultClient()
if err != nil {
return nil, err
}
if err := c.SendDef(def); err != nil {
return nil, err
}
synthID := c.NextSynthID()
return defaultGroup.Synth(def.Name, synthID, AddToTail, nil)
} | go | func PlayDef(def *Synthdef) (*Synth, error) {
c, err := DefaultClient()
if err != nil {
return nil, err
}
if err := c.SendDef(def); err != nil {
return nil, err
}
synthID := c.NextSynthID()
return defaultGroup.Synth(def.Name, synthID, AddToTail, nil)
} | [
"func",
"PlayDef",
"(",
"def",
"*",
"Synthdef",
")",
"(",
"*",
"Synth",
",",
"error",
")",
"{",
"c",
",",
"err",
":=",
"DefaultClient",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"if",
"err",
... | // PlayDef plays a synthdef by sending the synthdef using
// DefaultClient, then immediately creating a synth node from the def. | [
"PlayDef",
"plays",
"a",
"synthdef",
"by",
"sending",
"the",
"synthdef",
"using",
"DefaultClient",
"then",
"immediately",
"creating",
"a",
"synth",
"node",
"from",
"the",
"def",
"."
] | 2b87756659e2b72d97cec43b6896ed01c0365097 | https://github.com/scgolang/sc/blob/2b87756659e2b72d97cec43b6896ed01c0365097/client.go#L501-L513 |
148,793 | scgolang/sc | conv.go | Midicps | func Midicps(note float32) float32 {
return float32(440) * float32(math.Pow(2, float64(note-69)/12.0))
} | go | func Midicps(note float32) float32 {
return float32(440) * float32(math.Pow(2, float64(note-69)/12.0))
} | [
"func",
"Midicps",
"(",
"note",
"float32",
")",
"float32",
"{",
"return",
"float32",
"(",
"440",
")",
"*",
"float32",
"(",
"math",
".",
"Pow",
"(",
"2",
",",
"float64",
"(",
"note",
"-",
"69",
")",
"/",
"12.0",
")",
")",
"\n",
"}"
] | // Midicps converts midi note values to frequency in Hz | [
"Midicps",
"converts",
"midi",
"note",
"values",
"to",
"frequency",
"in",
"Hz"
] | 2b87756659e2b72d97cec43b6896ed01c0365097 | https://github.com/scgolang/sc/blob/2b87756659e2b72d97cec43b6896ed01c0365097/conv.go#L8-L10 |
148,794 | scgolang/sc | client_buffer.go | AllocBuffer | func (c *Client) AllocBuffer(frames, channels int) (*Buffer, error) {
buf, err := c.sendBufAllocMsg(frames, channels)
if err != nil {
return nil, err
}
if err := c.awaitBufAllocReply(buf); err != nil {
return nil, err
}
return buf, nil
} | go | func (c *Client) AllocBuffer(frames, channels int) (*Buffer, error) {
buf, err := c.sendBufAllocMsg(frames, channels)
if err != nil {
return nil, err
}
if err := c.awaitBufAllocReply(buf); err != nil {
return nil, err
}
return buf, nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"AllocBuffer",
"(",
"frames",
",",
"channels",
"int",
")",
"(",
"*",
"Buffer",
",",
"error",
")",
"{",
"buf",
",",
"err",
":=",
"c",
".",
"sendBufAllocMsg",
"(",
"frames",
",",
"channels",
")",
"\n",
"if",
"err... | // AllocBuffer allocates a buffer on the server | [
"AllocBuffer",
"allocates",
"a",
"buffer",
"on",
"the",
"server"
] | 2b87756659e2b72d97cec43b6896ed01c0365097 | https://github.com/scgolang/sc/blob/2b87756659e2b72d97cec43b6896ed01c0365097/client_buffer.go#L9-L18 |
148,795 | scgolang/sc | client_buffer.go | QueryBuffer | func (c *Client) QueryBuffer(num int32) (*Buffer, error) {
if err := c.oscConn.Send(osc.Message{
Address: bufferQueryAddress,
Arguments: osc.Arguments{
osc.Int(num),
},
}); err != nil {
return nil, errors.Wrap(err, "sending buffer query message")
}
return c.awaitBufInfoReply()
} | go | func (c *Client) QueryBuffer(num int32) (*Buffer, error) {
if err := c.oscConn.Send(osc.Message{
Address: bufferQueryAddress,
Arguments: osc.Arguments{
osc.Int(num),
},
}); err != nil {
return nil, errors.Wrap(err, "sending buffer query message")
}
return c.awaitBufInfoReply()
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"QueryBuffer",
"(",
"num",
"int32",
")",
"(",
"*",
"Buffer",
",",
"error",
")",
"{",
"if",
"err",
":=",
"c",
".",
"oscConn",
".",
"Send",
"(",
"osc",
".",
"Message",
"{",
"Address",
":",
"bufferQueryAddress",
"... | // QueryBuffer gets information about a buffer from scsynth. | [
"QueryBuffer",
"gets",
"information",
"about",
"a",
"buffer",
"from",
"scsynth",
"."
] | 2b87756659e2b72d97cec43b6896ed01c0365097 | https://github.com/scgolang/sc/blob/2b87756659e2b72d97cec43b6896ed01c0365097/client_buffer.go#L81-L91 |
148,796 | scgolang/sc | client_buffer.go | ReadBuffer | func (c *Client) ReadBuffer(path string, num int32, channels ...int) (*Buffer, error) {
buf, err := c.sendBufReadMsg(path, num, channels...)
if err != nil {
return nil, err
}
if err := c.awaitBufReadReply(buf); err != nil {
return nil, err
}
return buf, nil
} | go | func (c *Client) ReadBuffer(path string, num int32, channels ...int) (*Buffer, error) {
buf, err := c.sendBufReadMsg(path, num, channels...)
if err != nil {
return nil, err
}
if err := c.awaitBufReadReply(buf); err != nil {
return nil, err
}
return buf, nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"ReadBuffer",
"(",
"path",
"string",
",",
"num",
"int32",
",",
"channels",
"...",
"int",
")",
"(",
"*",
"Buffer",
",",
"error",
")",
"{",
"buf",
",",
"err",
":=",
"c",
".",
"sendBufReadMsg",
"(",
"path",
",",
... | // ReadBuffer tells the server to read an audio file and load it into a buffer. | [
"ReadBuffer",
"tells",
"the",
"server",
"to",
"read",
"an",
"audio",
"file",
"and",
"load",
"it",
"into",
"a",
"buffer",
"."
] | 2b87756659e2b72d97cec43b6896ed01c0365097 | https://github.com/scgolang/sc/blob/2b87756659e2b72d97cec43b6896ed01c0365097/client_buffer.go#L130-L139 |
148,797 | scgolang/sc | defs.go | RegisterSynthdef | func RegisterSynthdef(name string, f UgenFunc) error {
synthdefsMu.Lock()
defer synthdefsMu.Unlock()
if _, ok := Synthdefs[name]; ok {
return errors.New("synthdef already registered: " + name)
}
Synthdefs[name] = NewSynthdef(name, f)
return nil
} | go | func RegisterSynthdef(name string, f UgenFunc) error {
synthdefsMu.Lock()
defer synthdefsMu.Unlock()
if _, ok := Synthdefs[name]; ok {
return errors.New("synthdef already registered: " + name)
}
Synthdefs[name] = NewSynthdef(name, f)
return nil
} | [
"func",
"RegisterSynthdef",
"(",
"name",
"string",
",",
"f",
"UgenFunc",
")",
"error",
"{",
"synthdefsMu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"synthdefsMu",
".",
"Unlock",
"(",
")",
"\n",
"if",
"_",
",",
"ok",
":=",
"Synthdefs",
"[",
"name",
"]",
... | // RegisterSynthdef registers a synthdef with this package.
// It returns an error if a synthdef is already registered with the provided name. | [
"RegisterSynthdef",
"registers",
"a",
"synthdef",
"with",
"this",
"package",
".",
"It",
"returns",
"an",
"error",
"if",
"a",
"synthdef",
"is",
"already",
"registered",
"with",
"the",
"provided",
"name",
"."
] | 2b87756659e2b72d97cec43b6896ed01c0365097 | https://github.com/scgolang/sc/blob/2b87756659e2b72d97cec43b6896ed01c0365097/defs.go#L15-L23 |
148,798 | scgolang/sc | ugen.go | NewUgen | func NewUgen(name string, rate int8, specialIndex int16, numOutputs int, inputs ...Input) *Ugen {
CheckRate(rate)
if numOutputs <= 0 {
panic("numOutputs must be a positive int")
}
// TODO: validate specialIndex
u := &Ugen{
Name: name,
Rate: rate,
SpecialIndex: specialIndex,
NumOutputs: ... | go | func NewUgen(name string, rate int8, specialIndex int16, numOutputs int, inputs ...Input) *Ugen {
CheckRate(rate)
if numOutputs <= 0 {
panic("numOutputs must be a positive int")
}
// TODO: validate specialIndex
u := &Ugen{
Name: name,
Rate: rate,
SpecialIndex: specialIndex,
NumOutputs: ... | [
"func",
"NewUgen",
"(",
"name",
"string",
",",
"rate",
"int8",
",",
"specialIndex",
"int16",
",",
"numOutputs",
"int",
",",
"inputs",
"...",
"Input",
")",
"*",
"Ugen",
"{",
"CheckRate",
"(",
"rate",
")",
"\n\n",
"if",
"numOutputs",
"<=",
"0",
"{",
"pan... | // NewUgen is a factory function for creating new Ugen instances.
// Panics if rate is not AR, KR, or IR.
// Panics if numOutputs <= 0. | [
"NewUgen",
"is",
"a",
"factory",
"function",
"for",
"creating",
"new",
"Ugen",
"instances",
".",
"Panics",
"if",
"rate",
"is",
"not",
"AR",
"KR",
"or",
"IR",
".",
"Panics",
"if",
"numOutputs",
"<",
"=",
"0",
"."
] | 2b87756659e2b72d97cec43b6896ed01c0365097 | https://github.com/scgolang/sc/blob/2b87756659e2b72d97cec43b6896ed01c0365097/ugen.go#L43-L76 |
148,799 | scgolang/sc | ugen.go | Add | func (u *Ugen) Add(val Input) Input {
return binOpAdd(u.Rate, u, val, u.NumOutputs)
} | go | func (u *Ugen) Add(val Input) Input {
return binOpAdd(u.Rate, u, val, u.NumOutputs)
} | [
"func",
"(",
"u",
"*",
"Ugen",
")",
"Add",
"(",
"val",
"Input",
")",
"Input",
"{",
"return",
"binOpAdd",
"(",
"u",
".",
"Rate",
",",
"u",
",",
"val",
",",
"u",
".",
"NumOutputs",
")",
"\n",
"}"
] | // Add adds an input to a ugen node. | [
"Add",
"adds",
"an",
"input",
"to",
"a",
"ugen",
"node",
"."
] | 2b87756659e2b72d97cec43b6896ed01c0365097 | https://github.com/scgolang/sc/blob/2b87756659e2b72d97cec43b6896ed01c0365097/ugen.go#L94-L96 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.